home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / newbrow.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  98.0 KB  |  2,848 lines

  1. //---------------------------------------------------------------------------
  2. //Borland C++Builder
  3. //Copyright (c) 1987, 1998 Borland International Inc. All Rights Reserved.
  4. //---------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include <vcl.h>
  7. #include <assert.h>
  8. #include <math.h>
  9. #include <registry.hpp>
  10. #pragma hdrstop
  11.  
  12. #include "reblddlg.h"
  13. #include "NewBrow.h"
  14. #include "about.h"
  15. //---------------------------------------------------------------------------
  16. #pragma package(smart_init)
  17. #pragma resource "*.dfm"
  18. TMainForm *MainForm;
  19. //---------------------------------------------------------------------------
  20. __fastcall TMainForm::TMainForm(TComponent* Owner)
  21.     : TForm(Owner)
  22. {
  23.     Application->OnHint = ShowHint;
  24. }
  25. //---------------------------------------------------------------------------
  26. void __fastcall TMainForm::ShowHint(TObject *Sender)
  27. {
  28.      StatusBar->SimpleText = Application->Hint;
  29. }
  30.  
  31. void __fastcall TMainForm::FormCreate(TObject *Sender)
  32. {
  33.    // Initialize Database
  34.     GetRegInfo();
  35.     WriteRegKeys();
  36.     ClassOrgDB->Params->Values["Path"] = LocalTablesDir;
  37.  
  38.     // Open Tables
  39.     try {
  40.         VCLTable->Open();
  41.     }
  42.     catch (EDatabaseError& E) {
  43.         ShowMessage(E.Message + "Recopy vcltable.* files from cd!");
  44.            return;
  45.     }
  46.  
  47.     Application->Title = "VCL Object Browser";
  48.     Application->Icon->LoadFromFile(LocalTablesDir + "Browser.ico");
  49.        DestTable->Open();
  50.        ClassListTab->Open();
  51.        RawVCLTable = new TCloneTable(VCLTable, True);
  52.        RawVCLTable->Open();
  53.  
  54.        // Initialize Variables
  55.        MemberSearch = false;
  56.        InitializedTable = false;
  57.        MembPgCtl->MultiLine = true;
  58.        MembersLV->Parent = MembPgCtl;
  59.        MembersLV->Align = alBottom;
  60.        ParsingHeaders = false;
  61.        DeleteTabs = false;
  62.        IsOperator = false;
  63. }
  64. //------------------------------------------------------------
  65. void __fastcall TMainForm::FormShow(TObject *Sender)
  66. {
  67.     // Setup registry stuff
  68.     TRegistry *MyRegistry = new TRegistry();
  69.     String Key;
  70.     String Key2;
  71.     String Key3;
  72.     const String Temp = "\\software\\borland\\VCL Object Browser\\";
  73.     Key = Temp + "colors";
  74.     Key2 = Temp + "fonts";
  75.     Key3 = Temp + "fonts\\size";
  76.  
  77.     // Load background colors from registry
  78.     try {
  79.            MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
  80.            assert(MyRegistry->OpenKey(Key, false));
  81.            DeclareRE->Color = static_cast<TColor>
  82.             (StrToInt(MyRegistry->ReadString("Declaration")));
  83.            DefineRE->Color = static_cast<TColor>
  84.             (StrToInt(MyRegistry->ReadString("Definition")));
  85.            ClassLB->Color = static_cast<TColor>
  86.             (StrToInt(MyRegistry->ReadString("QuickClass")));
  87.            MembersLV->Color = static_cast<TColor>
  88.             (StrToInt(MyRegistry->ReadString("MemberList")));
  89.            Grid->Color = static_cast<TColor>
  90.             (StrToInt(MyRegistry->ReadString("Grid")));
  91.            hppFileRE->Color = static_cast<TColor>
  92.             (StrToInt(MyRegistry->ReadString("HeaderPage")));
  93.            pasFileRE->Color = static_cast<TColor>
  94.             (StrToInt(MyRegistry->ReadString("DefinitionPage")));
  95.  
  96.           // Load fonts from registry
  97.            MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
  98.            assert(MyRegistry->OpenKey(Key2, false));
  99.            DeclareRE->Font->Color = static_cast<TColor>
  100.             (StrToInt(MyRegistry->ReadString("Declaration")));
  101.            DefineRE->Font->Color = static_cast<TColor>
  102.             (StrToInt(MyRegistry->ReadString("Definition")));
  103.            ClassLB->Font->Color = static_cast<TColor>
  104.             (StrToInt(MyRegistry->ReadString("QuickClass")));
  105.            MembersLV->Font->Color = static_cast<TColor>
  106.             (StrToInt(MyRegistry->ReadString("MemberList")));
  107.            hppFileRE->Font->Color = static_cast<TColor>
  108.             (StrToInt(MyRegistry->ReadString("HeaderPage")));
  109.            pasFileRE->Font->Color = static_cast<TColor>
  110.             (StrToInt(MyRegistry->ReadString("DefinitionPage")));
  111.            Grid->Columns->Items[1]->Font->Color = static_cast<TColor>
  112.             (StrToInt(MyRegistry->ReadString("Grid")));
  113.            Grid->Columns->Items[2]->Font->Color = static_cast<TColor>
  114.             (StrToInt(MyRegistry->ReadString("Grid")));
  115.            Grid->Columns->Items[3]->Font->Color = static_cast<TColor>
  116.             (StrToInt(MyRegistry->ReadString("Grid")));
  117.            Grid->Columns->Items[4]->Font->Color = static_cast<TColor>
  118.             (StrToInt(MyRegistry->ReadString("Grid")));
  119.  
  120.            // Load font size
  121.            MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
  122.            assert(MyRegistry->OpenKey(Key3, false));
  123.            DeclareRE->Font->Size = StrToInt(MyRegistry->
  124.                                    ReadString("Declaration"));
  125.            DefineRE->Font->Size = StrToInt(MyRegistry->
  126.                                    ReadString("Definition"));
  127.            ClassLB->Font->Size = StrToInt(MyRegistry->
  128.                                    ReadString("QuickClass"));
  129.            MembersLV->Font->Size = StrToInt(MyRegistry->
  130.                                    ReadString("MemberList"));
  131.            hppFileRE->Font->Size = StrToInt(MyRegistry->
  132.                                    ReadString("HeaderPage"));
  133.            pasFileRE->Font->Size = StrToInt(MyRegistry->
  134.                                    ReadString("DefinitionPage"));
  135.            Grid->Columns->Items[1]->Font->Size = StrToInt(MyRegistry->
  136.                                    ReadString("Grid"));
  137.            Grid->Columns->Items[2]->Font->Size = StrToInt(MyRegistry->
  138.                                    ReadString("Grid"));
  139.            Grid->Columns->Items[3]->Font->Size = StrToInt(MyRegistry->
  140.                                    ReadString("Grid"));
  141.            Grid->Columns->Items[4]->Font->Size = StrToInt(MyRegistry->
  142.                                    ReadString("Grid"));
  143.        TFontStyles FStyle;
  144.        ClassLB->Font->Style = FStyle;
  145.        }
  146.        catch(ERegistryException &E) {
  147.            ShowMessage(E.Message);
  148.         delete MyRegistry;
  149.         return;
  150.     }
  151.        delete MyRegistry;
  152.     ClassLB->SetFocus();
  153. }
  154. //------------------------------------------------------------
  155.  
  156. void __fastcall TMainForm::FormActivate(TObject *Sender)
  157. {
  158.        const char* String1 = "You are about to build the VCL table!";
  159.        if (InitializedTable) return;
  160.        if (!VCLTable->RecordCount) {
  161.         Enabled = false;
  162.            if (::MessageBox(0, String1,
  163.                      "Attention", MB_OKCANCEL) == IDCANCEL) {
  164.             Enabled = true;
  165.              return;
  166.         }
  167.         Enabled = true;
  168.         RebuildVCLTabMi(Sender);
  169.        }
  170.    InitializedTable = true;
  171.    LoadClasses();
  172. }
  173. //------------------------------------------------------------
  174.  
  175. void TMainForm::GetRegInfo()
  176. {
  177.     String BCBPath;
  178.     const String KeyStr = "\\software\\borland\\C++Builder\\3.0";
  179.     TRegistry *MyRegistry = new TRegistry();
  180.     MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
  181.  
  182.     try {
  183.           if (MyRegistry->OpenKey(KeyStr, false)) {
  184.               BCBPath = MyRegistry->ReadString("RootDir");
  185.             if (!BCBPath.IsEmpty()) {
  186.                  LocalVclSource = BCBPath + "\\source\\";
  187.                   LocalVclHeaders = BCBPath + "\\include\\vcl\\";
  188.                   LocalTablesDir = BCBPath + "\\examples\\classbrw\\";
  189.             }
  190.             else ShowMessage("Failed to read RootDir");
  191.                MyRegistry->CloseKey(); 
  192.         }
  193.         else ShowMessage("Couldn't open key " + KeyStr);
  194.     }
  195.     catch(ERegistryException &E) {
  196.         ShowMessage(E.Message);
  197.         delete MyRegistry;
  198.         return;
  199.     }
  200.     delete MyRegistry;
  201. }
  202.  
  203. void TMainForm::WriteRegKeys()
  204. {
  205.     // Check for registry keys and create if no exist
  206.     const String Key1 = "\\software\\borland\\VCL Object Browser\\colors";
  207.     const String Key2 = "\\software\\borland\\VCL Object Browser\\fonts";
  208.     const String Key3 = "\\software\\borland\\VCL Object Browser\\fonts\\size";
  209.  
  210.     TRegistry *MyRegistry = new TRegistry();
  211.  
  212.     try {
  213.           MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
  214.           if (!MyRegistry->KeyExists(Key1)) {
  215.             if(MyRegistry->OpenKey(Key1, True)) {
  216.                 // note 16777215 is the color white default for background
  217.                 MyRegistry->WriteString("Declaration", "16777215");
  218.                 MyRegistry->WriteString("Definition", "16777215");
  219.                 MyRegistry->WriteString("DefinitionPage", "16777215");
  220.                 MyRegistry->WriteString("Grid", "16777215");
  221.                 MyRegistry->WriteString("HeaderPage", "16777215");
  222.                 MyRegistry->WriteString("MemberList", "16777215");
  223.                 MyRegistry->WriteString("QuickClass", "16777215");
  224.                 MyRegistry->CloseKey();
  225.             }
  226.         }
  227.           if (!MyRegistry->KeyExists(Key2)) {
  228.              if (MyRegistry->OpenKey(Key2, True)) {
  229.                 // note 0 is the default font color black
  230.                  MyRegistry->WriteString("Declaration", "0");
  231.                  MyRegistry->WriteString("Definition", "0");
  232.                  MyRegistry->WriteString("DefinitionPage", "0");
  233.                  MyRegistry->WriteString("Grid", "0");
  234.                  MyRegistry->WriteString("HeaderPage", "0");
  235.                  MyRegistry->WriteString("MemberList", "0");
  236.                  MyRegistry->WriteString("QuickClass", "0");
  237.                  MyRegistry->CloseKey();
  238.             }
  239.         }
  240.           if (!MyRegistry->KeyExists(Key3)) {
  241.              if (MyRegistry->OpenKey(Key3, True)) {
  242.                  // note 8 is default font size
  243.                 MyRegistry->WriteString("Declaration", "8");
  244.                  MyRegistry->WriteString("Definition", "8");
  245.                  MyRegistry->WriteString("DefinitionPage", "8");
  246.                  MyRegistry->WriteString("Grid", "8");
  247.                  MyRegistry->WriteString("HeaderPage", "8");
  248.                  MyRegistry->WriteString("MemberList", "8");
  249.                  MyRegistry->WriteString("QuickClass", "8");
  250.                  MyRegistry->CloseKey();
  251.             }
  252.         }
  253.     }
  254.     catch(ERegistryException &E) {
  255.            ShowMessage(E.Message);
  256.         delete MyRegistry;
  257.         return;
  258.     }
  259.     delete MyRegistry;
  260. }
  261.  
  262.  
  263. void __fastcall TMainForm::RebuildVCLTabMi(TObject *Sender)
  264. {
  265.     String Password;
  266.     String OneChar;
  267.     String Line;
  268.     String HeaderName;
  269.     int CharCount;
  270.     int pcg;
  271.     int hCount = 0;
  272.     int TotFiles = 0;
  273.     bool end = false;
  274.     bool last = false;
  275.     bool CLast = false;
  276.     bool SelectOK = false;
  277.     bool GotPasName = false;
  278.     bool ValidHeader = false;
  279.     TSearchEngine *PasFileSearch;
  280.     WIN32_FIND_DATA fd;
  281.     HANDLE hFile = NULL;
  282.     String HeadersChar = LocalVclHeaders + "*.h*";
  283.     ClassLB->Clear();
  284.  
  285.     try {
  286.         ParsingHeaders = true;
  287.  
  288.         // Set a password if desired
  289.            if (VCLTable->RecordCount !=0 ) {
  290.             Password = "Rebuild";
  291.               SelectOK = InputQuery("Enter Password",
  292.                      "Warning Rebuilding VCL table!!",Password);
  293.               if (!SelectOK) return;
  294.              else
  295.                  if (Password != "Rebuild") return;
  296.         }
  297.  
  298.         // Show progress form
  299.            TabRebuildStats = new TTabRebuildStats(this);
  300.            TabRebuildStats->HeaderBar->Show();
  301.            TabRebuildStats->TotalBar->Show();
  302.            TabRebuildStats->ParseLabel->Show();
  303.            TabRebuildStats->TotalLab->Show();
  304.            TabRebuildStats->HeaderLab->Show();
  305.            TabRebuildStats->Caption = "Building VCL Table";
  306.            TabRebuildStats->Left = ceil((ClientWidth/2)-
  307.                                    (TabRebuildStats->Width/2));
  308.            TabRebuildStats->Top =  ceil((ClientHeight/2)-
  309.                                   (TabRebuildStats->Height/2));
  310.            TabRebuildStats->Show();
  311.            Enabled = false;
  312.            TabRebuildStats->HeaderBar->Position = 1;
  313.            TabRebuildStats->HeaderLab->Caption = "emptying table";
  314.            Application->ProcessMessages();
  315.  
  316.         // Empty the VCL table if necessary
  317.            VCLTable->Close();
  318.            try {
  319.             VCLTable->EmptyTable();
  320.         }
  321.            catch (EDatabaseError& E) {
  322.             ShowMessage(E.Message + "Recopy vcltable.* files from cd!");
  323.             Screen->Cursor = crDefault;
  324.             TabRebuildStats->Hide();
  325.             return;
  326.         }
  327.  
  328.         //  Empty classes.db Fill up during parse
  329.         ClassListTab->Close();
  330.            try {
  331.             ClassListTab->EmptyTable();
  332.         }
  333.         catch (EDatabaseError& E) {
  334.             ShowMessage(E.Message + "Recopy vcltable.* files from cd!");
  335.         }
  336.         ClassListTab->Open();
  337.  
  338.         // Start header parsing process
  339.            VCLTable->Open();
  340.            Screen->Cursor = crHourGlass;
  341.            DestTable->DisableControls();
  342.            PasFileSearch = new TSearchEngine();
  343.  
  344.         // find out how many file are in dir
  345.         while (!end) {
  346.             if (!hFile) hFile = FindFirstFile(HeadersChar.c_str(), &fd);
  347.             else{
  348.                 CLast = FindNextFile(hFile, &fd);
  349.                 if (!CLast) break;
  350.             }
  351.             TotFiles++;
  352.         }
  353.  
  354.         hFile = NULL;
  355.         end = false;
  356.         while (!end) {
  357.             if (!hFile) hFile = FindFirstFile(HeadersChar.c_str(), &fd);
  358.             else {
  359.                 last = FindNextFile(hFile, &fd);
  360.                 if (!last) break;
  361.             }
  362.  
  363.                   HeaderName = String(fd.cFileName);
  364.             TabRebuildStats->HeaderLab->Caption = HeaderName;
  365.             CharCount = 0;
  366.             GotPasName = false;
  367.             PasFileName = "";
  368.             OneChar = "";
  369.             CurrentHeader = HeaderName;
  370.             hppFileRE->Clear();
  371.             ValidHeader = true;
  372.             if (HeaderName.LowerCase() == "utilcls.h") ValidHeader = false;
  373.             try {
  374.                 hppFileRE->Lines->LoadFromFile
  375.                             (LocalVclHeaders + CurrentHeader);
  376.                 TabRebuildStats->HeaderBar->Max =
  377.                             static_cast<Word>(
  378.                             hppFileRE->Lines->Count);
  379.                 TabRebuildStats->HeaderBar->Position = 1;
  380.                 Application->ProcessMessages();
  381.             }
  382.             catch(EFOpenError& E) {
  383.                 ValidHeader = false;
  384.             }
  385.  
  386.                if (ValidHeader) {
  387.                 // get pas file name
  388.                 pasFileRE->Clear();
  389.                 PasFileSearch->SearchForString(".pas", 1, 0,
  390.                                                "Include");
  391.                 if (PasFileSearch->PosFound!=-1) {
  392.                     Line = hppFileRE->Lines->
  393.                     Strings[PasFileSearch->LineNumFound];
  394.                        while (!GotPasName) {
  395.                         OneChar = Line.SubString((PasFileSearch->PosFound) -
  396.                             (PasFileSearch->LinePosOne) - CharCount, 1);
  397.                           GotPasName =((OneChar == " ") || (OneChar == "/") ||
  398.                             (OneChar == "'"));
  399.                           if (!GotPasName) {
  400.                             AppendStr(OneChar ,PasFileName);
  401.                              PasFileName = OneChar;
  402.                              CharCount++;
  403.                         }
  404.                     }
  405.                        AppendStr(PasFileName,".pas");
  406.                 }
  407.                 DestTable->Close();
  408.                 DestTable->TableName = "main2.db";
  409.                 DestTable->Open();
  410.                 DestTable->Close();
  411.                 DestTable->EmptyTable();
  412.                 DestTable->Open();
  413.                 HppToDestTable();
  414.                 Screen->Cursor = crDefault;
  415.                 BatchMove1->Execute();
  416.                 hCount++;
  417.             }
  418.             pcg = ((float)hCount / (float)TotFiles) * 100;
  419.             if (pcg) {
  420.                 TabRebuildStats->TotalLab->Caption =
  421.                                      IntToStr(pcg) + " %";
  422.                 TabRebuildStats->TotalBar->Position = pcg;
  423.                 Application->ProcessMessages();
  424.             }
  425.         }
  426.  
  427.         // clean up
  428.            DestTable->Close();
  429.            DestTable->EnableControls();
  430.            Screen->Cursor=crDefault;
  431.            TabRebuildStats->Hide();
  432.            VCLTable->Close();
  433.            VCLTable->TableName = "vcltable.db";
  434.            VCLTable->Open();
  435.            VCLTable->Refresh();
  436.            RawVCLTable->Refresh();
  437.            Grid->Refresh();
  438.            RawVCLTable->First();
  439.            ShowMessage("Successful Build");
  440.            Enabled = true;
  441.            ParsingHeaders = false;
  442.     }
  443.        catch(...) {
  444.         ShowMessage("Corrupt Table! Recopy vcltable.* files from cd!");
  445.         delete TabRebuildStats;
  446.           return;
  447.     }
  448.     LoadClasses();
  449.       delete TabRebuildStats;
  450.     delete PasFileSearch;
  451. }
  452. //------------------------------------------------------------
  453.  
  454. // Using the dest table that handles 1 header file parsement
  455. void TMainForm::ConvertTableToTabs()
  456. {
  457.    // run a query to get class names
  458.     MembersLV->Items->Clear();
  459.     DestTabQry->Close();
  460.     DestTabQry->Open();
  461.     ClearTabs();
  462.  
  463.    // Create tabs from query
  464.     while (!DestTabQry->Eof) {
  465.           TTabSheet *NewTabSheet = new TTabSheet(this);
  466.           NewTabSheet->Caption = DestTabQryClassName->AsString;
  467.           NewTabSheet->PageControl= MembPgCtl;
  468.         MembersLV->Parent = NewTabSheet;
  469.            MembersLV->Align = alClient;
  470.           DestTabQry->Next();
  471.     }
  472. }
  473.  
  474. void __fastcall TMainForm::SelectATab(TObject *Sender)
  475. {
  476.     // Handle tab select event
  477.        if (DeleteTabs) return;
  478.     MembersLV->Parent = MembPgCtl->ActivePage;
  479.     MembersLV->Align = alClient;
  480.     MembersLV->ViewStyle = vsList;
  481.     Application->ProcessMessages();
  482.        Screen->Cursor = crHourGlass;
  483.        CurrentTab = MembPgCtl->ActivePage->Caption;
  484.        ClassLBSel = CurrentTab;
  485.  
  486.     // Filter the VCL table with the tab caption
  487.        RawVCLTable->DisableControls();
  488.        RawVCLTable->Filtered = false;
  489.        RawVCLTable->SetRange(OPENARRAY(TVarRec,(CurrentTab)),
  490.                                OPENARRAY(TVarRec,(CurrentTab)));
  491.  
  492.        CurrentHeader = RawVCLTable->
  493.                     FieldByName("Header")->AsString;
  494.  
  495.        CurrentSource = RawVCLTable->
  496.                     FieldByName("Misc")->AsString;
  497.  
  498.     // Load the header.hpp and source.cpp files
  499.        DeclareRE->Clear();
  500.        DefineRE->Clear();
  501.        hppFileRE->Clear();
  502.        try {
  503.       hppFileRE->Lines->
  504.                 LoadFromFile(LocalVclHeaders + CurrentHeader);
  505.       HeaderTab->Caption = CurrentHeader;
  506.     }
  507.     catch (EFOpenError& E) {
  508.             ShowMessage(E.Message);
  509.             Screen->Cursor = crDefault;
  510.             return;
  511.     }
  512.        pasFileRE->Clear();
  513.        LoadSourcePage();
  514.        TableToListStrings(CurrentTab);
  515.     MembersLV->Repaint();
  516.     Application->ProcessMessages();
  517.        RawVCLTable->EnableControls();
  518.        Screen->Cursor = crDefault;
  519. }
  520. //------------------------------------------------------------
  521.  
  522. void TMainForm::TableToListStrings(const String ClassName)
  523. {
  524.     int q;
  525.     int ParamNum;
  526.        String FinalString;
  527.        String RecClassName;
  528.        String MemberName;
  529.        String MemberType;
  530.        String ReturnType;
  531.        String ScopeColor;
  532.        String PType[8];
  533.        String PObject[8];
  534.     String pt = "PType";
  535.     String ot = "PObject";
  536.     String TPos;
  537.     String OPos;
  538.        bool Break;
  539.        bool DataProperty;
  540.        TListItem *NewItem;
  541.  
  542.     // initialize
  543.        Break = false;
  544.        MembersLV->Items->Clear();
  545.  
  546.     // since our table has been filtered to only show one class with
  547.     // with all its members, lets extract the class members one record at a time.
  548.  
  549.        while ((!Break) && (!RawVCLTable->Eof)) {
  550.           FinalString = "";
  551.           RecClassName = RawVCLTable->FieldByName("ClassName")->AsString;
  552.  
  553.         // get class member info from table
  554.           if (ClassName == RecClassName) {
  555.             ReturnType = RawVCLTable->FieldByName("ReturnType")->AsString;
  556.              MemberName = RawVCLTable->FieldByName("MemberName")->AsString;
  557.             MemberType = RawVCLTable->FieldByName("Member")->AsString;
  558.              ScopeColor = RawVCLTable->FieldByName("Scope")->AsString;
  559.              ParamNum = RawVCLTable->FieldByName("Ps")->AsInteger;
  560.             DataProperty = ((MemberType == "property") && (!ParamNum));
  561.  
  562.             // Start building a ListView item String from table info
  563.             // obtained from above and assign an image index
  564.             FinalString = "";
  565.  
  566.             // if not a function do this
  567.             if ((MemberType == "data") || (DataProperty)) {
  568.                 AppendStr(FinalString, MemberName);
  569.                     NewItem = MembersLV->Items->Add();
  570.                     NewItem->Caption = FinalString;
  571.                     NewItem->ImageIndex = FindImageIndex(ScopeColor, MemberType);
  572.             }
  573.             // else if it is a function with only a void parameter
  574.             else {
  575.                 if (ParamNum == 0) {
  576.                        AppendStr(FinalString, MemberName);
  577.                     if (MemberType == "property")
  578.                         AppendStr(FinalString, " ={");
  579.                     else AppendStr(FinalString, " (");
  580.             }
  581.  
  582.             // build a function String that has parameters from 0 to 8
  583.              if (ParamNum > 0)  {
  584.                  PType[0] = RawVCLTable->FieldByName("PType1")->AsString;
  585.                  PObject[0] = RawVCLTable->FieldByName("PObject1")->AsString;
  586.                  AppendStr(FinalString, MemberName);
  587.                  if (MemberType == "property") AppendStr(FinalString," ={");
  588.                  else AppendStr(FinalString, " (");
  589.                 AppendStr(FinalString, PType[0]);
  590.                 AppendStr(FinalString, " ");
  591.                  AppendStr(FinalString, PObject[0]);
  592.              }
  593.  
  594.             for (q = 1; q < 8; q++) {
  595.                 if (ParamNum > q) {
  596.                     TPos = pt + IntToStr(q + 1);
  597.                     OPos = ot + IntToStr(q + 1);
  598.                        PType[q] = RawVCLTable->FieldByName(TPos)->AsString;
  599.                       PObject[q] = RawVCLTable->FieldByName(OPos)->AsString;
  600.                       AppendStr(FinalString, ",");
  601.                       AppendStr(FinalString, PType[q]);
  602.                     AppendStr(FinalString, " ");
  603.                     AppendStr(FinalString, PObject[q]);
  604.                 }
  605.             }
  606.             // handle properties differently
  607.                if (MemberType == "property") AppendStr(FinalString," }");
  608.                else AppendStr(FinalString," )");
  609.  
  610.             // Add the member to the member listbox
  611.             NewItem = MembersLV->Items->Add();
  612.             NewItem->Caption = FinalString;
  613.             NewItem->ImageIndex = FindImageIndex(ScopeColor, MemberType);
  614.             }
  615.             RawVCLTable->Next();
  616.         }
  617.         else Break = true;
  618.     }
  619. }
  620.  
  621. void __fastcall TMainForm::MembersLVClick(TObject *Sender)
  622. {
  623.     String MemberType;
  624.        String RetTypeSel;
  625.        String ParamArray[7];
  626.        int ParamQty;
  627.        if ((!MembersLV->ItemFocused) || (MembersLV-> ItemFocused->Caption == "Class Member List"))
  628.         return;
  629.     else
  630.         CurrentTab=MembPgCtl->ActivePage->Caption;
  631.           RawVCLTable->DisableControls();
  632.           RawVCLTable->First();
  633.  
  634.         // Take selected item and find in table
  635.           StringToTablePos(MembersLV->ItemFocused->Caption,
  636.                          CurrentTab);
  637.  
  638.         // Once record found, get certain field values
  639.           MemberNameSel = RawVCLTable->
  640.                         FieldByName("MemberName")->AsString;
  641.           RetTypeSel = RawVCLTable->
  642.                         FieldByName("ReturnType")->AsString;
  643.           LoadDeclCode(RetTypeSel + MembersLV->ItemFocused->
  644.                      Caption);
  645.           MemberType = RawVCLTable->
  646.                      FieldByName("Member")->AsString;
  647.         ParamQty = RawVCLTable->
  648.                      FieldByName("Ps")->AsInteger;
  649.         ParamArray[0] = RawVCLTable->
  650.                      FieldByName("PType1")->AsString;
  651.         ParamArray[1] = RawVCLTable->
  652.                      FieldByName("PType2")->AsString;
  653.         ParamArray[2] = RawVCLTable->
  654.                      FieldByName("PType3")->AsString;
  655.         ParamArray[3] = RawVCLTable->
  656.                      FieldByName("PType4")->AsString;
  657.         ParamArray[4] = RawVCLTable->
  658.                      FieldByName("PType5")->AsString;
  659.         ParamArray[5] = RawVCLTable->
  660.                      FieldByName("PType6")->AsString;
  661.         ParamArray[6] = RawVCLTable->
  662.                      FieldByName("PType7")->AsString;
  663.         ParamArray[7] = RawVCLTable->
  664.                      FieldByName("PType8")->AsString;
  665.         String HeaderType = RawVCLTable->
  666.                      FieldByName("Header")->AsString;
  667.  
  668.         // Load the Declaration and definition
  669.         if ((HeaderType.LowerCase() == "dstring.h") ||
  670.             (HeaderType.LowerCase() == "sysdefs.h") ||
  671.             (HeaderType.LowerCase() == "wstring.h"))
  672.             LoadCppDef(ParamArray, ParamQty);
  673.         else
  674.             LoadPasCode(MemberType, RetTypeSel +
  675.                         MembersLV->ItemFocused->Caption);
  676.           Screen->Cursor = crDefault;
  677.           RawVCLTable->EnableControls();
  678. }
  679. //------------------------------------------------------------
  680. void TMainForm::StringToTablePos(const String SelectedText, const String ClassName)
  681. {
  682.     bool Match = false;
  683.     bool DataProperty;
  684.     int q;
  685.     int ParamNum;
  686.     String FinalString;
  687.     String RecClassName;
  688.     String MemberName;
  689.     String MemberType;
  690.     String ReturnType;
  691.     String PType[8];
  692.     String PObject[8];
  693.     String pt = "PType";
  694.     String ot = "PObject";
  695.     String TPos;
  696.     String OPos;
  697.  
  698.     // since the table is still filtered to show only the class members
  699.     // letÆs iterate thru the table piecing together each record and comparing
  700.     // it with the ListView selection until we find a match.
  701.  
  702.     while ((!RawVCLTable->Eof) && (!Match)) {
  703.         FinalString = "";
  704.         ReturnType = RawVCLTable->FieldByName("ReturnType")->AsString;
  705.         MemberName = RawVCLTable->FieldByName("MemberName")->AsString;
  706.         MemberType = RawVCLTable->FieldByName("Member")->AsString;
  707.         RecClassName = RawVCLTable->FieldByName("ClassName")->AsString;
  708.         ParamNum = RawVCLTable->FieldByName("Ps")->AsInteger;
  709.  
  710.         // Is it a data property
  711.         DataProperty = ((MemberType == "property") && (!ParamNum));
  712.         if (ClassName == RecClassName) {
  713.             FinalString = "";
  714.             // if data member
  715.             if ((MemberType == "data") || (DataProperty))
  716.                 AppendStr(FinalString, MemberName);
  717.             else {
  718.                 // Start building String from table info
  719.                 if (ParamNum == 0) {
  720.                     AppendStr(FinalString, MemberName);
  721.                     if (MemberType == "property")
  722.                         AppendStr(FinalString, " ={");
  723.                     else AppendStr(FinalString, " (");
  724.                 }
  725.  
  726.                 // if the member has parameters
  727.                 if (ParamNum > 0)  {
  728.                     PType[0] = RawVCLTable->FieldByName("PType1")->AsString;
  729.                     PObject[0] = RawVCLTable->FieldByName("PObject1")->AsString;
  730.                     AppendStr(FinalString, MemberName);
  731.                     if (MemberType == "property")
  732.                         AppendStr(FinalString, " ={");
  733.                     else AppendStr(FinalString, " (");
  734.                     AppendStr(FinalString, PType[0]);
  735.                     AppendStr(FinalString, " ");
  736.                     AppendStr(FinalString, PObject[0]);
  737.                 }
  738.  
  739.                 //for parameters greater than 1
  740.                 for (q = 1; q < 8; q++) {
  741.                     if (ParamNum > q) {
  742.                         TPos = pt + IntToStr(q + 1);
  743.                         OPos = ot + IntToStr(q + 1);
  744.                         PType[q] = RawVCLTable->FieldByName(TPos)->AsString;
  745.                         PObject[q] = RawVCLTable->FieldByName(OPos)->AsString;
  746.                         AppendStr(FinalString, ",");
  747.                         AppendStr(FinalString, PType[q]);
  748.                         AppendStr(FinalString, " ");
  749.                         AppendStr(FinalString, PObject[q]);
  750.                     }
  751.                 }
  752.  
  753.                 if (MemberType == "property")
  754.                     AppendStr(FinalString," }");
  755.                 else AppendStr(FinalString," )");
  756.             }
  757.         }
  758.         //here is where we compare for a match
  759.         Match = SelectedText == FinalString;
  760.         if (!Match) RawVCLTable->Next();
  761.     }
  762.     RawVCLTable->EnableControls();
  763. }
  764.  
  765. void TMainForm::LoadClasses()
  766. {
  767.     // Load up VCL class list
  768.        ClassLB->Clear();
  769.        ClassListTab->Open();
  770.        ClassListTab->First();
  771.  
  772.     // iterate through the table
  773.        while (!ClassListTab->Eof) {
  774.         ClassLB->Items->Add(ClassListTabClassName->AsString);
  775.           ClassListTab->Next();
  776.     }
  777.     // if ClassLB has multiselect set to true highlight first
  778.     ClassLB->Perform(LB_SETSEL,true,0);
  779. }
  780.  
  781. void TMainForm::HppToDestTable()
  782. {
  783.     bool OneLinerClass;
  784.     bool DerivedClass;
  785.     bool CommentLine;
  786.     bool Break;
  787.     bool Done;
  788.     bool a;
  789.     bool b;
  790.     bool c;
  791.     int x;
  792.     int p;
  793.     int StrLength;
  794.     int CopyLength;
  795.     int FirstSearch;
  796.     int EndOfSearch;
  797.     long ComLinePos;
  798.     String OneLineOfCode;
  799.     String ExtractClass;
  800.     String OneChar;
  801.     String TempString;
  802.     SecondClass = "";
  803.     EndOfSearch = 0;
  804.     FirstSearch = 0;
  805.     TSearchEngine *ClassSearch = new TSearchEngine();
  806.     TSearchEngine *CommentSearch = new TSearchEngine();
  807.     ClassSearch->LineNumFound =0;
  808.     CommentSearch->LineNumFound =0;
  809.     ClassSearch->PosFound = 0;
  810.     CommentSearch->PosFound = 0;
  811.        ClearTabs();
  812.  
  813.        // Extracting Class names
  814.        while (EndOfSearch!=-1) {
  815.         if (ParsingHeaders) ClassListTab->Append();
  816.         OneLinerClass = false;
  817.           DerivedClass = false;
  818.         Break = false;
  819.           ExtractClass = "";
  820.          // Find "class" from pos 0
  821.           ClassSearch->SearchForString("class ", 1, FirstSearch, "Include");
  822.           TabRebuildStats->HeaderBar->Position =
  823.                 static_cast<Word>(ClassSearch->LineNumFound);
  824.  
  825.         // Is class line a comment line
  826.           CommentSearch->SearchForString("//", 1,
  827.                          ClassSearch->LinePosOne, "Include");
  828.           CommentLine = ClassSearch->LineNumFound==
  829.                       CommentSearch->LineNumFound;
  830.         if (!CommentLine) {
  831.              CommentSearch->SearchForString("/*", 1,
  832.                          ClassSearch->LinePosOne, "Include");
  833.                CommentLine = ClassSearch->LineNumFound==
  834.                       CommentSearch->LineNumFound;
  835.         }
  836.  
  837.         a = CommentLine;
  838.           b = ClassSearch->PosFound < CommentSearch->PosFound;
  839.           c = ClassSearch->PosFound == -1;
  840.         if (c) {
  841.             CommentSearch->PosFound = 999999;
  842.              TabRebuildStats->HeaderBar->Position =
  843.                              TabRebuildStats->HeaderBar->Max;
  844.           }
  845.           if ((a && b && !c) || (!a && !c)) {
  846.             OneLineOfCode = hppFileRE->Lines->
  847.                          Strings[ClassSearch->LineNumFound];
  848.             StrLength = OneLineOfCode.Length();
  849.  
  850.              // skip blank lines
  851.              while (!StrLength) {
  852.                 OneLineOfCode = hppFileRE->
  853.                 Lines->Strings[ClassSearch->LineNumFound +1 ];
  854.                 StrLength = OneLineOfCode.Length();
  855.             }
  856.             if (CommentLine) {
  857.                 ComLinePos = CommentSearch->PosFound -
  858.                              CommentSearch->LinePosOne;
  859.                 OneLineOfCode = hppFileRE->
  860.                     Lines->Strings[ClassSearch->LineNumFound];
  861.                 OneLineOfCode = OneLineOfCode.SubString(0,
  862.                                               ComLinePos);
  863.                 StrLength = OneLineOfCode.Length();
  864.             }
  865.  
  866.              // check for template classes
  867.              if (OneLineOfCode.Pos("template")) Break = true;
  868.                 if (OneLineOfCode.Pos("class DELPHIRETURN OleVariant")) Break = true;
  869.                 if (OneLineOfCode.Pos(".")) Break = true;
  870.                 
  871.             //  check for forward declaration
  872.              for (p = 1; p <= StrLength+1; p++) {
  873.                 OneChar = OneLineOfCode.SubString(p, 1);
  874.  
  875.                  if (OneChar == ";") Break = true;
  876.                  if (OneChar == ":") DerivedClass = true;
  877.                  if (OneChar == "{") OneLinerClass = true;
  878.             }
  879.  
  880.              // extract derived class
  881.              if (DerivedClass) {
  882.                 // Get the 2nd derivation class name
  883.                 CopyLength = StrLength;
  884.                 TempString = "";
  885.                 Done = false;
  886.                 SecondClass  = "";
  887.                    while (!Done) {
  888.                     TempString = OneLineOfCode.SubString(CopyLength, 1);
  889.                        if (TempString == ":") Done = true;
  890.                     if ((TempString == " ") && (CopyLength != StrLength)) Done = true ;
  891.                     if ((TempString != "{") && (!Done) && (TempString != " ")) {
  892.                         AppendStr(TempString, SecondClass);
  893.                           SecondClass = TempString;
  894.                     }
  895.                        CopyLength--;
  896.                 }
  897.                 // Get Class Name
  898.                 x = 1;
  899.                 while ((x!=StrLength+1) && (!Break)) {
  900.                     OneChar = "";
  901.                        OneChar = OneLineOfCode.SubString(x, 1);
  902.                        if (OneChar == ":") {
  903.                         OneChar = " ";
  904.                           x = x-1;
  905.                           OneChar = OneLineOfCode.SubString(x, 1);
  906.                           while (OneChar    ==    " ") {
  907.                             x--;
  908.                              OneChar = OneLineOfCode.SubString(x, 1);
  909.                         }
  910.                           while (OneChar!=" ") {
  911.                             OneChar = OneLineOfCode.SubString(x, 1);
  912.                              x--;
  913.                         }
  914.                           x = x+2;
  915.                           OneChar = OneLineOfCode.SubString(x, 1);
  916.                           while ((OneChar != " ") && (OneChar != ":")) {
  917.                             ExtractClass = ExtractClass + OneChar;
  918.                              x++;
  919.                              OneChar = OneLineOfCode.SubString(x, 1);
  920.                         }
  921.                           Break = true;
  922.                           TabRebuildStats->ClassLab->Caption =
  923.                                                ExtractClass;
  924.                         if (ParsingHeaders) {
  925.                             ClassListTabClassName->AsString =
  926.                                                ExtractClass;
  927.                             ClassListTab->Post();
  928.                         }
  929.                           Application->ProcessMessages();
  930.                           ExtractClassMembers(ClassSearch->PosFound,
  931.                                         ExtractClass);
  932.                     }
  933.                 x++;
  934.                 }
  935.             SecondClass="";
  936.             }
  937.  
  938.             // This is a base class type
  939.             if ((!DerivedClass) && (OneLinerClass)) {
  940.                    x = 1;
  941.                   while ((x!=StrLength+1) && (!Break)) {
  942.                 OneChar = "";
  943.                    OneChar = OneLineOfCode.SubString(x, 1);
  944.                    if (OneChar == "{") {
  945.                       x = x-1;
  946.                       OneChar = OneLineOfCode.SubString(x, 1);
  947.                       while (OneChar == " ") {
  948.                         x--;
  949.                          OneChar = OneLineOfCode.SubString(x, 1);
  950.                     }
  951.                       while (OneChar!=" ") {
  952.                         OneChar = OneLineOfCode.SubString(x, 1);
  953.                          x--;
  954.                     }
  955.                       x = x+2;
  956.                       OneChar = OneLineOfCode.SubString(x, 1);
  957.                       while ((OneChar!=" ") && (OneChar!="{")) {
  958.                         ExtractClass = ExtractClass + OneChar;
  959.                          x++;
  960.                          OneChar = OneLineOfCode.SubString(x, 1);
  961.                     }
  962.                       Break = true;
  963.                       TabRebuildStats->ClassLab->Caption =
  964.                                                ExtractClass;
  965.                     if (ParsingHeaders) {
  966.                         ClassListTabClassName->AsString =
  967.                                                ExtractClass;
  968.                         ClassListTab->Post();
  969.                     }
  970.                       Application->ProcessMessages();
  971.                       ExtractClassMembers(ClassSearch->PosFound,
  972.                                                 ExtractClass);
  973.                     }
  974.                     x++;
  975.                 }
  976.                 }
  977.  
  978.             // Start of two line class declaration
  979.             if ((!OneLinerClass) && (!DerivedClass) &&
  980.                                                 (!Break)) {
  981.                    x = StrLength;
  982.                    OneChar = OneLineOfCode.SubString(x, 1);
  983.                    while (OneChar == " ") {
  984.                       x--;
  985.                       OneChar = OneLineOfCode.SubString(x,1);
  986.                   }
  987.                    while (OneChar != " ") {
  988.                       OneChar = OneLineOfCode.SubString(x, 1);
  989.                       x--;
  990.                   }
  991.                    x = x + 2;
  992.                    OneChar = OneLineOfCode.SubString(x, 1);
  993.                    while (x != StrLength + 1) {
  994.                   ExtractClass = ExtractClass + OneChar;
  995.                   x++;
  996.                   OneChar = OneLineOfCode.SubString(x, 1);
  997.                   }
  998.                   TabRebuildStats->ClassLab->Caption=
  999.                                            ExtractClass;
  1000.                 if (ParsingHeaders) {
  1001.                     ClassListTabClassName->AsString =
  1002.                                                ExtractClass;
  1003.                     ClassListTab->Post();
  1004.                 }
  1005.                   Application->ProcessMessages();
  1006.                    ExtractClassMembers(ClassSearch->PosFound,
  1007.                             ExtractClass);//  2 line class
  1008.             }
  1009.         }
  1010.  
  1011.           EndOfSearch = ClassSearch->PosFound;
  1012.           FirstSearch = ClassSearch->NewSearchPos;
  1013.         }
  1014.     TObject* Sender = new TObject();
  1015.     if (!ParsingHeaders) {
  1016.            ConvertTableToTabs();
  1017.            SelectATab(Sender);
  1018.     }
  1019.     delete Sender;
  1020.     delete ClassSearch;
  1021.     delete CommentSearch;
  1022. }
  1023.  
  1024. void TMainForm::ExtractClassMembers(const int ClassPosition,
  1025.                                     const String ClassName) {
  1026.     String ScopeLab[4]= {"public:", "__published:", "protected:",
  1027.                          "private:"};
  1028.     String AMember;
  1029.     String ClassMember;
  1030.     String OneChar;
  1031.     bool HasScopes[4];
  1032.     bool OneScopeDone;
  1033.     bool FoundEnd;
  1034.     bool Break;
  1035.     bool FoundOpenBrkt;
  1036.     bool FoundEqual;
  1037.     int ScopeLine;
  1038.     int StrLength;
  1039.     int LineLength;
  1040.     int MembersCount;
  1041.     int MyCount;
  1042.     int MoreMembers;
  1043.     int b;
  1044.     int n;
  1045.     int r;
  1046.     int x;
  1047.     int sc;
  1048.     int EndBracket;
  1049.        long MemberPosOne;
  1050.     long P[4];
  1051.     long L[4];
  1052.     long q;
  1053.     long h;
  1054.     TSearchEngine *ScopeMembers[4];
  1055.        ScopeMembers[0] = new TSearchEngine();
  1056.     ScopeMembers[1] = new TSearchEngine();
  1057.     ScopeMembers[2] = new TSearchEngine();
  1058.     ScopeMembers[3] = new TSearchEngine();
  1059.        TSearchEngine *BeginClassBracket = new TSearchEngine();
  1060.        AMember = "";
  1061.        Break = false;
  1062.        MyCount = 0;
  1063.        FoundOpenBrkt = false;
  1064.  
  1065.     // After we found a valid class, lets find the scope ops
  1066.        BeginClassBracket->SearchForString("{", 1, ClassPosition,
  1067.                                        "Include");
  1068.        ScopeMembers[0]->SearchForString("public:", 1,
  1069.                                     ClassPosition,"Include");
  1070.        ScopeMembers[1]->SearchForString("__published:", 1,
  1071.                                     ClassPosition,"Include");
  1072.        ScopeMembers[2]->SearchForString("protected:", 1,
  1073.                                     ClassPosition,"Include");
  1074.        ScopeMembers[3]->SearchForString("private:", 1,
  1075.                                     ClassPosition,"Include");
  1076.        b = BeginClassBracket->LineNumFound;
  1077.        MoreMembers = 2;
  1078.        DestTable->Close();
  1079.        DestTable->TableName = "main2.db";
  1080.        DestTable->Open();
  1081.  
  1082.     // Once in the class find first and last {}
  1083.     while (!Break) {
  1084.         x = 1;
  1085.           StrLength = hppFileRE->Lines->
  1086.                                         Strings[b].Length();
  1087.           while ((x != StrLength+1) && (!Break)) {
  1088.             OneChar = hppFileRE->Lines->
  1089.                                 Strings[b].SubString(x, 1);
  1090.              if (OneChar == "{") {
  1091.                 FoundOpenBrkt = true;
  1092.                 MyCount = MyCount + 1;
  1093.             }
  1094.              if (OneChar == "}") MyCount = MyCount-1;
  1095.              x++;
  1096.              Break = (!MyCount) && (FoundOpenBrkt);
  1097.         }
  1098.           b++;
  1099.     }
  1100.     b=b-1;
  1101.  
  1102.        MemberPosOne = hppFileRE->
  1103.                                Perform(EM_LINEINDEX, b, 0);
  1104.     // Need to know where class ends
  1105.        EndBracket = MemberPosOne + (x-1);
  1106.     P[0] = ScopeMembers[0]->PosFound;
  1107.     P[1] = ScopeMembers[1]->PosFound;
  1108.     P[2] = ScopeMembers[2]->PosFound;
  1109.     P[3] = ScopeMembers[3]->PosFound;
  1110.     HasScopes[0] = (P[0] < EndBracket) && (P[0] != -1);
  1111.     HasScopes[1] = (P[1] < EndBracket) && (P[1] != -1);
  1112.     HasScopes[2] = (P[2] < EndBracket) && (P[2] != -1);
  1113.     HasScopes[3] = (P[3] < EndBracket) && (P[3] != -1);
  1114.     L[0] = ScopeMembers[0]->LineNumFound;
  1115.     L[1] = ScopeMembers[1]->LineNumFound;
  1116.     L[2] = ScopeMembers[2]->LineNumFound;
  1117.     L[3] = ScopeMembers[3]->LineNumFound;
  1118.  
  1119.     for (sc = 0; sc < 4; sc++) {
  1120.        while (HasScopes[sc]) {
  1121.            n = 1;
  1122.           OneScopeDone = false;
  1123.           while (!OneScopeDone) {
  1124.             switch (sc) { // Check if pos is within class
  1125.                 case 0:
  1126.                     q = L[0] + n;
  1127.                     if ((q == L[1]) || (q == L[2]) || (q == L[3])
  1128.                           || (q == b)) OneScopeDone = true;
  1129.                     break;
  1130.                 case 1:
  1131.                     q = L[1] + n;
  1132.                     if ((q == L[0]) || (q == L[2]) ||(q == L[3])
  1133.                           || (q == b)) OneScopeDone = true;
  1134.                     break;
  1135.                 case 2:
  1136.                     q = L[2] + n;
  1137.                     if ((q == L[0]) || (q == L[1]) ||(q == L[3])
  1138.                           || (q == b)) OneScopeDone = true;
  1139.                     break;
  1140.                 case 3:
  1141.                     q = L[3] + n;
  1142.                     if ((q == L[0]) || (q == L[1]) ||(q == L[2])
  1143.                           || (q == b)) OneScopeDone = true;
  1144.                     break;
  1145.             }
  1146.              ClassMember = "";
  1147.              ClassMember = hppFileRE->Lines->
  1148.                                             Strings[L[sc] + n];
  1149.  
  1150.              if (ClassMember.Pos("public:") ||
  1151.                  ClassMember.Pos("private:") ||
  1152.                  ClassMember.Pos("__published:") ||
  1153.                  ClassMember.Pos("protected:"))
  1154.                 OneScopeDone = true;
  1155.              ScopeLine = L[sc] + n;
  1156.  
  1157.             // Is this a garbage line
  1158.              while (IsItABadLine(ClassMember,ScopeLine)) {
  1159.                 ClassMember = hppFileRE->
  1160.                                     Lines->Strings[L[sc] + n + 1];
  1161.                 if (ClassMember.Pos("public:") ||
  1162.                  ClassMember.Pos("private:") ||
  1163.                  ClassMember.Pos("__published:") ||
  1164.                  ClassMember.Pos("protected:"))
  1165.                 OneScopeDone = true;
  1166.                 switch (sc) {
  1167.                 case 0:
  1168.                     h = L[0] + n + 1;
  1169.                     if ((h == L[1]) || (h == L[2]) || (h == L[3])
  1170.                          || (h == b)) OneScopeDone = true;
  1171.                     break;
  1172.                 case 1:
  1173.                     h = L[1] + n + 1;
  1174.                     if ((h == L[0]) || (h == L[2]) ||(h == L[3])
  1175.                       || (h == b)) OneScopeDone = true;
  1176.                     break;
  1177.                 case 2:
  1178.                     h = L[2] + n + 1;
  1179.                     if ((h == L[0]) || (h == L[1]) ||(h == L[3])
  1180.                       || (h == b)) OneScopeDone = true;
  1181.                     break;
  1182.                 case 3:
  1183.                     h = L[3] + n + 1;
  1184.                     if ((h == L[0]) || (h == L[1]) ||(h == L[2])
  1185.                       || (h == b)) OneScopeDone = true;
  1186.                     break;
  1187.                 }
  1188.                    ScopeLine = L[sc] + n + 1;
  1189.                    n++;
  1190.             }
  1191.  
  1192.              if (!OneScopeDone) {
  1193.                 FoundEqual = false;
  1194.                 FoundEnd = false;
  1195.                 MembersCount = 1;
  1196.                 // Append multiple line functions
  1197.                 while (!FoundEnd) {
  1198.                        LineLength = ClassMember.Length();
  1199.                        for (r = 1; r <= (LineLength + 1); r++)    {
  1200.                           OneChar = ClassMember.SubString(r, 1);
  1201.                           if (OneChar == "=") FoundEqual = true;
  1202.                           if (OneChar == ";") FoundEnd = true;
  1203.                           if ((OneChar == "}") && (!FoundEqual))
  1204.                             FoundEnd = true;
  1205.                     }
  1206.                    if (!FoundEnd) ClassMember = ClassMember +
  1207.                             hppFileRE->Lines->
  1208.                             Strings[L[sc] + n + MembersCount];
  1209.                    MembersCount++;
  1210.                    }
  1211.                 String Temp = ScopeLab[sc].SubString(1,
  1212.                                     ScopeLab[sc].Length() -1);
  1213.                 MemberToTable(ClassMember,Temp,
  1214.                               ClassName, ScopeLine);
  1215.             }
  1216.              n = n + MembersCount - 2;
  1217.              n++;
  1218.         }
  1219.         // Are the scopes declared more than once
  1220.           HasScopes[sc] = false;
  1221.           ScopeMembers[sc]->SearchForString(ScopeLab[sc],
  1222.                 MoreMembers, ClassPosition, "Include");
  1223.           if ((ScopeMembers[sc]->PosFound < EndBracket) &&
  1224.             (ScopeMembers[sc]->PosFound != -1)) {
  1225.             HasScopes[sc] = true;
  1226.              MoreMembers++;
  1227.             P[0] = ScopeMembers[0]->PosFound;
  1228.             P[1] = ScopeMembers[1]->PosFound;
  1229.             P[2] = ScopeMembers[2]->PosFound;
  1230.             P[3] = ScopeMembers[3]->PosFound;
  1231.                HasScopes[0] = (P[0] < EndBracket) && (P[0] != -1);
  1232.                HasScopes[1] = (P[1] < EndBracket) && (P[1] != -1);
  1233.                HasScopes[2] = (P[2] < EndBracket) && (P[2] != -1);
  1234.                HasScopes[3] = (P[3] < EndBracket) && (P[3] != -1);
  1235.             L[0] = ScopeMembers[0]->LineNumFound;
  1236.             L[1] = ScopeMembers[1]->LineNumFound;
  1237.             L[2] = ScopeMembers[2]->LineNumFound;
  1238.             L[3] = ScopeMembers[3]->LineNumFound;
  1239.          }
  1240.     }
  1241.     }
  1242.     delete[] ScopeMembers;
  1243.     delete BeginClassBracket;
  1244. }
  1245.  
  1246. void TMainForm::MemberToTable(const String MemberDeclaration,
  1247.             const String MyScope, const String CppClassName,
  1248.             const int MemberLineNumber)
  1249. {
  1250.     // Get all vcltable fields info and post to table
  1251.     int k;
  1252.     int v;
  1253.     int StrLength;
  1254.     int y;
  1255.     int IsItAProperty;
  1256.     int Len;
  1257.     long MemberPosOne;
  1258.     int Temp;
  1259.     int Temp2;
  1260.     long Temp3;
  1261.  
  1262.     bool EndOfParams;
  1263.     bool Break;
  1264.     bool IsItAFunction;
  1265.     bool a;
  1266.     bool b;
  1267.     bool c;
  1268.     bool d;
  1269.     bool e;
  1270.     String OneChar;
  1271.     String ClassMemberName;
  1272.     String ObjectNames[8];
  1273.     String ObjectTypes[8];
  1274.     TExtractObjects *ExtractObjects;
  1275.     TSearchEngine *MemberCommentSearch;
  1276.  
  1277.     if (MemberDeclaration.Pos("operator")) IsOperator = true;
  1278.     DestTable->Append();
  1279.     MemberCommentSearch = new TSearchEngine();
  1280.     ExtractObjects = new TExtractObjects();
  1281.     IsItAFunction = false;
  1282.     Break = false;
  1283.     StrLength = MemberDeclaration.Length();
  1284.     y = 1;
  1285.     IsItAProperty = MemberDeclaration.Pos("__property");
  1286.  
  1287.     while ((y != StrLength+1) && (!Break)) {
  1288.         OneChar = "";
  1289.           OneChar = MemberDeclaration.SubString(y, 1);
  1290.         a = OneChar == "(";
  1291.         b = y == StrLength;
  1292.         c = OneChar == "=";
  1293.         d = !IsOperator;
  1294.         e = OneChar == "[";
  1295.  
  1296.          // For data and function members
  1297.           if ((a) || (b) || ((c) && (d)) || ((e) && (d))) {
  1298.             if (a) IsItAFunction = true;
  1299.              if (c) IsItAFunction = true;
  1300.  
  1301.             // skip comments and extract member type and name
  1302.             MemberPosOne = hppFileRE->
  1303.                     Perform(EM_LINEINDEX, MemberLineNumber, 0);
  1304.              MemberCommentSearch->SearchForString("*/", 1,
  1305.                                      MemberPosOne, "Include");
  1306.             Temp = MemberDeclaration.Pos("*/");
  1307.             Temp2 = MemberDeclaration.Pos("/*");
  1308.             Temp3 = Temp + MemberPosOne -1;
  1309.             if (Temp == 0) {
  1310.                 ExtractObjects->ExtractNameAndType(1 , y,
  1311.                             MemberDeclaration, "MemberName");
  1312.              IsOperator = false;
  1313.             }
  1314.             else {
  1315.                 // handle comments
  1316.                  if(Temp3 == MemberPosOne + y - 2) { // if at end of line
  1317.                     ExtractObjects->ExtractNameAndType(1 , Temp2,
  1318.                             MemberDeclaration, "MemberName");
  1319.                      IsOperator = false;
  1320.                 }
  1321.                 else { // Get name and type  if at begin of line
  1322.                     ExtractObjects->ExtractNameAndType(
  1323.                         (MemberCommentSearch->PosFound -
  1324.                           MemberPosOne) + 3,
  1325.                           y, MemberDeclaration, "MemberName");
  1326.                     IsOperator = false;
  1327.                 }
  1328.             }
  1329.              OneChar = ExtractObjects->ObjectName.SubString(0, 1);
  1330.  
  1331.             // make sure pointers are on type side
  1332.              if (OneChar == "*") {
  1333.                 Len = ExtractObjects->ObjectName.Length();
  1334.                 ExtractObjects->ObjectName = ExtractObjects->
  1335.                                 ObjectName.SubString(2, Len);
  1336.                 AppendStr(ExtractObjects->ObjectType, "*");
  1337.             }
  1338.  
  1339.             // Make sure references are on type side
  1340.              if (OneChar == "&") {
  1341.                 Len = ExtractObjects->ObjectName.Length();
  1342.                 ExtractObjects->ObjectName = ExtractObjects->
  1343.                                 ObjectName.SubString(2, Len);
  1344.                 AppendStr(ExtractObjects->ObjectType, "&");
  1345.             }
  1346.              ClassMemberName = ExtractObjects->ObjectName;
  1347.              DestTableMemberName->AsString = ClassMemberName;
  1348.              TabRebuildStats->MemberLab->Caption = ClassMemberName;
  1349.              Application->ProcessMessages();
  1350.              DestTableReturnType->AsString = ExtractObjects->
  1351.                                                     ObjectType;
  1352.              Break = true;
  1353.              EndOfParams = false;
  1354.              v = 0;
  1355.  
  1356.              // Extract parameters
  1357.              while ((!EndOfParams) && (v != StrLength+1)
  1358.                                          && (IsItAFunction)) {
  1359.                 k = 0;
  1360.                 v = y + 1;
  1361.                 OneChar = MemberDeclaration.SubString(v, 1);
  1362.                 if (OneChar == ")") EndOfParams = true;
  1363.                 if (OneChar == "}") EndOfParams = true;
  1364.                 ExtractObjects->LastCommaPosition = y;
  1365.                 while (!EndOfParams) {
  1366.                        OneChar = MemberDeclaration.SubString(v, 1);
  1367.                        if (OneChar == ")") EndOfParams = true;
  1368.                        if (OneChar == "}") EndOfParams = true;
  1369.                        if ((OneChar == ",") || (OneChar == ")")
  1370.                                      || (OneChar == "}")) {
  1371.                           ExtractObjects->ObjectName = "";
  1372.                           ExtractObjects->ObjectType = "";
  1373.                           ExtractObjects->ExtractNameAndType(
  1374.                             ExtractObjects->LastCommaPosition +
  1375.                             1, v, MemberDeclaration, "Parameter");
  1376.                           OneChar = ExtractObjects->
  1377.                                     ObjectName.SubString(0, 1);
  1378.                       if (OneChar == "*") {
  1379.                         Len = ExtractObjects->ObjectName.Length();
  1380.                         ExtractObjects->ObjectName =
  1381.                                  ExtractObjects->
  1382.                                  ObjectName.SubString(2, Len);
  1383.                          AppendStr(ExtractObjects->ObjectType, "*");
  1384.                      }
  1385.                       if (OneChar == "&") {
  1386.                         Len = ExtractObjects->ObjectName.Length();
  1387.                          ExtractObjects->ObjectName =
  1388.                                 ExtractObjects->
  1389.                                 ObjectName.SubString(2, Len);
  1390.                          AppendStr(ExtractObjects->ObjectType, "&");
  1391.                     }
  1392.                       ObjectNames[k] = ExtractObjects->ObjectName;
  1393.                       ObjectTypes[k] = ExtractObjects->ObjectType;
  1394.                       k++;
  1395.                       if (k==8) EndOfParams = true;
  1396.                       }
  1397.                 v++;
  1398.                 }
  1399.             }
  1400.             // Load up table fields before doing a post
  1401.             DestTablePType1->AsString = ObjectTypes[0];
  1402.             DestTablePType2->AsString = ObjectTypes[1];
  1403.             DestTablePType3->AsString = ObjectTypes[2];
  1404.             DestTablePType4->AsString = ObjectTypes[3];
  1405.             DestTablePType5->AsString = ObjectTypes[4];
  1406.             DestTablePType6->AsString = ObjectTypes[5];
  1407.             DestTablePType7->AsString = ObjectTypes[6];
  1408.             DestTablePType8->AsString = ObjectTypes[7];
  1409.             DestTablePObject1->AsString = ObjectNames[0];
  1410.             DestTablePObject2->AsString = ObjectNames[1];
  1411.             DestTablePObject3->AsString = ObjectNames[2];
  1412.             DestTablePObject4->AsString = ObjectNames[3];
  1413.             DestTablePObject5->AsString = ObjectNames[4];
  1414.             DestTablePObject6->AsString = ObjectNames[5];
  1415.             DestTablePObject7->AsString = ObjectNames[6];
  1416.             DestTablePObject8->AsString = ObjectNames[7];
  1417.  
  1418.             // Clear for reuse
  1419.             for (int w = 0; w < 8; w++) {
  1420.                 ObjectTypes[w] = "";
  1421.                 ObjectNames[w] = "";
  1422.             }
  1423.  
  1424.             if (!IsItAFunction) DestTablePs->AsInteger = 0;
  1425.             if (IsItAFunction) DestTablePs->AsInteger = k;
  1426.             DestTableSecondClass->AsString = SecondClass;
  1427.             DestTableHeader->AsString = CurrentHeader;
  1428.             DestTableScope->AsString = MyScope;
  1429.             DestTableClassName->AsString = CppClassName;
  1430.             DestTableMisc->AsString = PasFileName;
  1431.             if (IsItAFunction) {
  1432.                 if (CppClassName == ClassMemberName)
  1433.                      DestTableMember->AsString = "constructor";
  1434.                 else DestTableMember->AsString = "function";
  1435.             }
  1436.             if (!IsItAFunction) DestTableMember->AsString = "data";
  1437.             if (IsItAProperty) DestTableMember->AsString = "property";
  1438.             if ((ClassMemberName == String()) ||
  1439.                (DestTableReturnType->AsString == String()))
  1440.                 DestTable->Cancel();
  1441.             else
  1442.                 DestTable->Post();
  1443.         }
  1444.           y++;
  1445.     }
  1446.     delete ExtractObjects;
  1447.     delete MemberCommentSearch;
  1448. }
  1449.  
  1450. bool TMainForm::IsItABadLine(const String Line,
  1451.                                  const int DefinedLineNumber)
  1452. {
  1453.     int Len;
  1454.     int x;
  1455.        long MemberPosOne;
  1456.        bool FoundSemicolon = false;
  1457.     bool FoundOpenBracket = false;
  1458.     bool BadLine = true;
  1459.     bool FoundPound = false;
  1460.        String OneChar;
  1461.        TSearchEngine *DefineLineSearch;
  1462.        DefineLineSearch = new TSearchEngine();
  1463.  
  1464.     // Garbage line detection
  1465.        Len = Line.Length();
  1466.        for (x = 1; x <= (Len+1); x++) {
  1467.         OneChar = Line.SubString(x, 1);
  1468.           if (OneChar == ";") FoundSemicolon = true;
  1469.           if (OneChar == "#") FoundPound = true;
  1470.           if ((OneChar == "(") || (OneChar == "{")) {
  1471.              FoundOpenBracket = true;
  1472.              MemberPosOne = hppFileRE->
  1473.                     Perform(EM_LINEINDEX, DefinedLineNumber, 0);
  1474.              DefineLineSearch->SearchForString("define", 1,
  1475.                                      MemberPosOne, "Include");
  1476.          if ((DefineLineSearch->PosFound < MemberPosOne + x)
  1477.           && (DefineLineSearch->PosFound != -1) && (FoundPound))
  1478.               FoundOpenBracket = false;
  1479.          }
  1480.     }
  1481.     if (FoundSemicolon) BadLine = false;
  1482.     if (FoundOpenBracket) BadLine = false;
  1483.     if (Line.Pos("//")) BadLine = true;
  1484.     if (Line.Pos("MESSAGE_HANDLER")) BadLine = true;
  1485.     if (Line.Pos("BEGIN_MESSAGE_MAP")) BadLine = true;
  1486.     if (Line.Pos("END_MESSAGE_MAP")) BadLine = true;
  1487.  
  1488.     delete DefineLineSearch;
  1489.     return(BadLine);
  1490. }
  1491.  
  1492. void __fastcall TMainForm::ClassLBClick(TObject *Sender)
  1493. {
  1494.     // Class listbox event
  1495.     ClassLBSel = ClassLB->Items->Strings[ClassLB->ItemIndex];
  1496.     ProcessSelectedClass();
  1497. }
  1498. //------------------------------------------------------------
  1499.  
  1500. void __fastcall TMainForm::MemberName1Click(TObject *Sender)
  1501. {
  1502.     bool SelectOK;
  1503.        String SearchMember;
  1504.  
  1505.        // Use VCL Table for sec indexes then refresh RawVCLTable
  1506.        SelectOK = InputQuery("SEARCH ENGINE", "Enter Member Name",
  1507.                            SearchMember);
  1508.        if (SelectOK) {
  1509.         Screen->Cursor = crHourGlass;
  1510.           VCLTable->IndexName = "MemberNameIndex";
  1511.           VCLTable->SetRange(OPENARRAY(TVarRec, (SearchMember)),
  1512.                          OPENARRAY(TVarRec, (SearchMember)));
  1513.           MainDS->DataSet = VCLTable;
  1514.           MemberSearch = true;
  1515.           if (!VCLTable->RecordCount) {
  1516.              ShowMessage(SearchMember +
  1517.                             " is not a VCL Class member !");
  1518.              VCLTable->IndexName = "";
  1519.              MainDS->DataSet = RawVCLTable;
  1520.              Grid->DataSource = MainDS;
  1521.              MemberSearch = false;
  1522.         }
  1523.     Screen->Cursor = crDefault;
  1524.     }
  1525.     MainPgCtl->ActivePage = MainPgCtl->Pages[3];
  1526. }
  1527. //------------------------------------------------------------
  1528.  
  1529. void __fastcall TMainForm::ShowRecordClick(TObject *Sender)
  1530. {
  1531.     if (MemberSearch) {
  1532.          ClassLBSel = VCLTable->FieldByName("ClassName")->
  1533.                                                     AsString;
  1534.          MemberSearch = false;
  1535.     }
  1536.     else
  1537.         ClassLBSel = RawVCLTable->FieldByName("ClassName")->
  1538.                                                     AsString;
  1539.     ProcessSelectedClass();
  1540. }
  1541. //------------------------------------------------------------
  1542.  
  1543. void __fastcall TMainForm::About1Click(TObject *Sender)
  1544. {
  1545.    AboutBox = new TAboutBox(this);
  1546.    AboutBox->ShowModal();
  1547.    delete AboutBox;
  1548. }
  1549. //------------------------------------------------------------
  1550.  
  1551. void __fastcall TMainForm::ClassName1Click(TObject *Sender)
  1552. {
  1553.     // Search for class by Name
  1554.     String SearchClass;
  1555.     bool SelectOK;
  1556.     TLocateOptions tlo;
  1557.     String S1 = " class not found!";
  1558.     String S2 = " Check case sensitivity or verify";
  1559.     String S3 = " possible TypeDef";
  1560.     String String4 = S1 + S2 + S3;
  1561.     SelectOK = InputQuery("SEARCH ENGINE", "Enter Class Name",
  1562.                              SearchClass);
  1563.     if (!SelectOK) return;
  1564.     if (SelectOK) {
  1565.         LocateSuccess = ClassListTab->Locate("ClassName",
  1566.                                             SearchClass, tlo);
  1567.         if (!LocateSuccess) {
  1568.             ShowMessage(SearchClass + String4);
  1569.             return;
  1570.         }
  1571.     ClassLBSel = SearchClass;
  1572.     ProcessSelectedClass();
  1573.     }
  1574.  
  1575. }
  1576. //------------------------------------------------------------
  1577.  
  1578. void __fastcall TMainForm::ViewHeaderClick(TObject *Sender)
  1579. {
  1580.     int LineFound;
  1581.     int LinePositionOne;
  1582.     int LineFound2;
  1583.     int LinePositionOne2;
  1584.  
  1585.     // View header file and highlight member name
  1586.     Show();
  1587.     LineFound2 = pasFileRE->Perform(EM_LINEFROMCHAR,
  1588.                            pasFileRE->SelStart, 0);
  1589.     if (LineFound2 && (pasFileRE->Lines->Count > 10)) {
  1590.         LinePositionOne2 = pasFileRE->Perform(EM_LINEINDEX,
  1591.                                                   LineFound2, 0);
  1592.         pasFileRE->Perform(EM_SETSEL, LinePositionOne2,
  1593.                LinePositionOne2 + pasFileRE->
  1594.                Lines->Strings[LineFound2].Length());
  1595.     }
  1596.        Application->ProcessMessages();
  1597.        LineFound = hppFileRE->Perform(EM_LINEFROMCHAR,
  1598.                         hppFileRE->SelStart, 0);
  1599.     if (LineFound) {
  1600.            LinePositionOne = hppFileRE->Perform(EM_LINEINDEX,
  1601.                                              LineFound, 0);
  1602.            hppFileRE->Perform(EM_SETSEL, LinePositionOne,
  1603.                LinePositionOne + hppFileRE->
  1604.                Lines->Strings[LineFound].Length());
  1605.     }
  1606. }
  1607. //------------------------------------------------------------
  1608.  
  1609. void __fastcall TMainForm::ViewSourceClick(TObject *Sender)
  1610. {     
  1611.     int LineFound;
  1612.        int LinePositionOne;
  1613.        int LineFound2;
  1614.        int LinePositionOne2;
  1615.  
  1616.     // View source file and highlight member name
  1617.        Show();
  1618.        LineFound2 = hppFileRE->Perform(EM_LINEFROMCHAR,
  1619.                            hppFileRE->SelStart, 0);
  1620.     if (LineFound2) {
  1621.            LinePositionOne2 = hppFileRE->Perform(EM_LINEINDEX,
  1622.                                                 LineFound2, 0);
  1623.            hppFileRE->Perform(EM_SETSEL, LinePositionOne2,
  1624.                LinePositionOne2 + hppFileRE->
  1625.                Lines->Strings[LineFound2].Length());
  1626.     }
  1627.        Application->ProcessMessages();
  1628.        LineFound = pasFileRE->Perform(EM_LINEFROMCHAR,
  1629.                         pasFileRE->SelStart, 0);
  1630.  
  1631.     if (LineFound && (pasFileRE->Lines->Count > 10)) {
  1632.            LinePositionOne = pasFileRE->Perform(EM_LINEINDEX,
  1633.                                              LineFound, 0);
  1634.            pasFileRE->Perform(EM_SETSEL, LinePositionOne,
  1635.                LinePositionOne + pasFileRE->
  1636.                Lines->Strings[LineFound].Length());
  1637.     }
  1638. }
  1639. //------------------------------------------------------------
  1640. void TMainForm::LoadDeclCode(const String LBString)
  1641. {
  1642.     int LineCount;
  1643.     int Len;
  1644.     int d;
  1645.     int LLen;
  1646.     int x;
  1647.     int OccurNum = 1;
  1648.     int BeginNote;
  1649.     int EndNote;
  1650.     int ClassPos;
  1651.     String CodeLine;
  1652.     String OneChar;
  1653.     String HMemberCondense;
  1654.     String CondensedString;
  1655.     bool Match = false;
  1656.     bool FirstChar = false;
  1657.     bool AnEqual;
  1658.     bool AnEnd;
  1659.     bool OpenCurley;
  1660.     bool CloseCurley;
  1661.     bool SemiColon;
  1662.     bool b;
  1663.     bool c;
  1664.     long Temp;
  1665.     TStringList *DeclareSList = new TStringList();
  1666.     TSearchEngine *MDeclareSearch = new TSearchEngine();
  1667.        DeclareSList->Clear();
  1668.  
  1669.        // Strip and condense for .hpp declaration
  1670.        LLen = LBString.Length();
  1671.        for(x = 1; x <= LLen; x++) {
  1672.         OneChar = LBString.SubString(x, 1);
  1673.           if ((OneChar != " ") && (OneChar != "\t"))
  1674.         CondensedString = CondensedString + OneChar;
  1675.     }
  1676.  
  1677.     // Search for MemberName only for PasFile only
  1678.        while (!Match) {
  1679.         MDeclareSearch->SearchForString(MemberNameSel, OccurNum,
  1680.                                         0, "Include");
  1681.           if (MDeclareSearch->PosFound == -1) {
  1682.             DeclareRE->Clear();
  1683.              DeclareRE->Lines->Add("Declaration not found!");
  1684.              return;
  1685.         }
  1686.         AnEqual = false;
  1687.           AnEnd = false;
  1688.           OpenCurley = false;
  1689.           CloseCurley = false;
  1690.           SemiColon = false;
  1691.           LineCount = 0;
  1692.           HMemberCondense = "";
  1693.         Temp = MDeclareSearch->LineNumFound;
  1694.  
  1695.         // Append multiple line functions
  1696.           while (!AnEnd) {
  1697.             d = 1;
  1698.              CodeLine = "";
  1699.              Len = hppFileRE->Lines->
  1700.                             Strings[Temp + LineCount].Length();
  1701.              while ((d != Len + 1) && (!AnEnd)) {
  1702.                  OneChar = hppFileRE->Lines->
  1703.                     Strings[Temp + LineCount].SubString(d, 1);
  1704.                 // handle note that has class in it
  1705.                 BeginNote = hppFileRE->Lines->
  1706.                     Strings[Temp + LineCount].Pos("/*");
  1707.                 EndNote = hppFileRE->Lines->
  1708.                     Strings[Temp + LineCount].Pos("*/");
  1709.  
  1710.                 ClassPos = hppFileRE->Lines->
  1711.                             Strings[Temp + LineCount].Pos("class");
  1712.                 if (ClassPos)
  1713.                      AnEnd = !((ClassPos > BeginNote) && (ClassPos < EndNote));
  1714.  
  1715.  
  1716.                 b = OneChar == "}";
  1717.                 c = OneChar == ";";
  1718.                  if (OneChar == "{") OpenCurley = true;
  1719.                  if (OneChar == "=") AnEqual = true;
  1720.                  if (b) CloseCurley = true;
  1721.                  if (c) SemiColon=true;
  1722.                  if ((c) && (CloseCurley) && (OpenCurley))
  1723.                                                  AnEnd = true;
  1724.                  if ((c) && (!OpenCurley) && (!AnEqual))
  1725.                                                  AnEnd = true;
  1726.                  if ((c) && (!OpenCurley) && (!CloseCurley))
  1727.                                               AnEnd = true;
  1728.                  if ((b) && (SemiColon) && (OpenCurley))
  1729.                                               AnEnd = true;
  1730.                  if ((b) && (!SemiColon) && (OpenCurley) &&
  1731.                                    (!AnEqual)) AnEnd = true;
  1732.  
  1733.                 // Once we found a source match ,condense it
  1734.                  if ((OneChar != " ") && (OneChar != "\t")) {
  1735.  
  1736.                      FirstChar = true;
  1737.                      HMemberCondense = HMemberCondense + OneChar;
  1738.                  }
  1739.                  if (FirstChar) CodeLine = CodeLine + OneChar;
  1740.                  d++;
  1741.              }
  1742.              DeclareSList->Add(CodeLine);
  1743.              FirstChar = false;
  1744.              LineCount++;
  1745.         }
  1746.           if (HMemberCondense.Pos(CondensedString))
  1747.             Match = true;
  1748.         else {
  1749.             OccurNum++;
  1750.             DeclareSList->Clear();
  1751.         }
  1752.     }
  1753.     DeclareRE->Lines->Clear();
  1754.     DeclareRE->Lines->AddStrings(DeclareSList);
  1755.     MainPgCtl->ActivePage = MainPgCtl->Pages[2];
  1756.     DeclareRE->SetFocus();
  1757.     DeclareRE->Perform(EM_SETSEL, 0, 0);
  1758.     delete DeclareSList;
  1759.     delete MDeclareSearch;
  1760. }
  1761.  
  1762. void TMainForm::LoadPasCode(const String MemberType,
  1763.                                 const String LBSelectMember)
  1764. {
  1765.     int n = 1;
  1766.     int k = 1;
  1767.     int Len;
  1768.     int EndPos;
  1769.     int BeginPos;
  1770.     int TryPos;
  1771.        bool FirstBegin = false;
  1772.     bool ExtractDone = false;;
  1773.     bool CppFile = false;
  1774.        String CheckLine;
  1775.        TSearchEngine* SearchForDef = new TSearchEngine();
  1776.        TStringList* SStringList = new TStringList();
  1777.  
  1778.     // Pascal constructor uses create
  1779.        DefLength = (CurrentTab + "."+ MemberNameSel).Length();
  1780.        if (MemberType == "constructor") {
  1781.         MemberNameSel = "Create";
  1782.         CurrentTab = "constructor " + CurrentTab;
  1783.     }
  1784.  
  1785.  
  1786.        SearchForDef->SearchForString(CurrentTab + "." +
  1787.                          MemberNameSel + "(", 1, 0, "Source");
  1788.     
  1789.        if (SearchForDef->PosFound == -1) {
  1790.         SearchForDef->SearchForString(CurrentTab + "." +
  1791.                          MemberNameSel + ";", 1, 0, "Source");
  1792.         if (SearchForDef->PosFound == -1) {
  1793.             SearchForDef->SearchForString(CurrentTab + "." +
  1794.                          MemberNameSel + ":", 1 , 0, "Source");
  1795.             if (SearchForDef->PosFound == -1) {
  1796.                 SearchForDef->SearchForString(CurrentTab +
  1797.                          "::" + MemberNameSel, 1, 0, "Source");
  1798.                 if (SearchForDef->PosFound != -1)
  1799.                  CppFile = true;
  1800.                 else {
  1801.                     DefineRE->Lines->Clear();
  1802.                     SStringList->Clear();
  1803.                     DefineRE->Lines->Strings[0] =
  1804.                     "No function or procedure source available!"; 
  1805.                 }
  1806.             }
  1807.         }
  1808.     }
  1809.  
  1810.     // For pascal file find begin and end
  1811.        if ((SearchForDef->PosFound != -1) && (!CppFile)) {
  1812.         DefineRE->Lines->Clear();
  1813.           SStringList->Add(pasFileRE->Lines->
  1814.                         Strings[SearchForDef->LineNumFound]);
  1815.           while (!ExtractDone) {
  1816.             CheckLine = pasFileRE->Lines->
  1817.                     Strings[SearchForDef->LineNumFound + n];
  1818.              Len = CheckLine.Length();
  1819.              BeginPos = CheckLine.Pos("begin");
  1820.              if ((BeginPos == 1) && (BeginPos == Len-4)) {
  1821.                 if (!FirstBegin) k=0;
  1822.                 FirstBegin = true;
  1823.                 k++;
  1824.             }
  1825.              BeginPos = CheckLine.Pos(" begin");
  1826.              if ((BeginPos) && (BeginPos == Len - 5)) {
  1827.                 if (!FirstBegin) k = 0;
  1828.                 FirstBegin = true;
  1829.                 k++;
  1830.             }
  1831.              TryPos = CheckLine.Pos("try");
  1832.              if ((TryPos == 1) && ((TryPos == Len - 4) ||
  1833.                                      (TryPos == Len - 3))) k++;
  1834.              TryPos = CheckLine.Pos(" try");
  1835.              if ((TryPos) && ((TryPos == Len - 4) ||
  1836.                                  (TryPos == Len - 3))) k++;
  1837.              EndPos = CheckLine.Pos("end else");
  1838.              if ((EndPos == 1) && ((EndPos == Len - 9) ||
  1839.                                  (EndPos == Len - 8)))k--;
  1840.             else
  1841.                 EndPos = CheckLine.Pos("end");
  1842.             if ((EndPos == 1) && ((EndPos == Len-4) ||
  1843.                                  (EndPos == Len-3))) k--;
  1844.  
  1845.              EndPos = CheckLine.Pos(" end else");
  1846.              if ((EndPos) && ((EndPos == Len - 9) ||
  1847.                                  (EndPos == Len - 8))) k--;
  1848.             else
  1849.                 EndPos = CheckLine.Pos(" end");
  1850.             if ((EndPos) && ((EndPos == Len-4) ||
  1851.                                   (EndPos == Len-3))) k--;
  1852.              if (!ExtractDone) SStringList->Add(CheckLine);
  1853.              if (!k) ExtractDone=true;
  1854.              n++;
  1855.         }
  1856.           DefineRE->Lines->AddStrings(SStringList);
  1857.     }
  1858.     delete SearchForDef;
  1859.        delete SStringList;
  1860. }
  1861. //------------------------------------------------------------
  1862.  
  1863. void __fastcall TMainForm::ParseHeaderClick(TObject *Sender)
  1864. {
  1865.     // For parsing 1 header at a time
  1866.     String OneChar;
  1867.     String Line;
  1868.        int CharCount;
  1869.        bool GotPasName;
  1870.  
  1871.        // Get File Name
  1872.        FileOpenDlg->InitialDir = LocalVclHeaders;
  1873.        FileOpenDlg->Options << ofHideReadOnly;
  1874.        FileOpenDlg->Filter = "*.hpp,*.h|*.hpp;*.h";
  1875.  
  1876.        if (FileOpenDlg->Execute()) {
  1877.         String temp = ExtractFileDir(FileOpenDlg->FileName) + "\\";
  1878.         if (temp.LowerCase() != LocalVclHeaders.LowerCase()) {
  1879.             ShowMessage("Sorry, VCL headers only!");
  1880.             return;
  1881.         }
  1882.           TabRebuildStats = new TTabRebuildStats(this);
  1883.           TabRebuildStats->HeaderBar->Show();
  1884.           TabRebuildStats->TotalBar->Hide();
  1885.           TabRebuildStats->TotalLab->Hide();
  1886.         TabRebuildStats->ParseLabel->Hide();
  1887.           TabRebuildStats->HeaderLab->Hide();
  1888.           TabRebuildStats->Caption = ("Parsing Header "+
  1889.                      ExtractFileName(FileOpenDlg->FileName));
  1890.           TabRebuildStats->Show();
  1891.           Application->ProcessMessages();
  1892.           Enabled = false;
  1893.           TSearchEngine* PasFileSearch = new TSearchEngine();
  1894.           MembPgCtl->MultiLine = false;
  1895.           CharCount = 0;
  1896.           GotPasName = false;
  1897.           PasFileName = "";
  1898.           OneChar = "";
  1899.  
  1900.           // reset controls
  1901.           ClassLB->Items->Clear();
  1902.           MembersLV->Items->Clear();
  1903.           Application->ProcessMessages();
  1904.           ClearTabs();
  1905.  
  1906.           // Change vcltable to point to dest table
  1907.           VCLTable->Close();
  1908.           VCLTable->TableName = DestTable->TableName;
  1909.        VCLTable->Open();
  1910.       
  1911.           Screen->Cursor = crHourGlass;
  1912.           CurrentHeader = ExtractFileName(FileOpenDlg->FileName);
  1913.           hppFileRE->Clear();
  1914.           try {
  1915.             hppFileRE->Lines->
  1916.                         LoadFromFile(FileOpenDlg->FileName);
  1917.              HeaderTab->Caption = CurrentHeader;
  1918.              TabRebuildStats->HeaderBar->Max = static_cast<Word>
  1919.                      (hppFileRE->Lines->Count);
  1920.         }
  1921.         catch(EFOpenError& E) {
  1922.             ShowMessage(E.Message);
  1923.             Screen->Cursor = crDefault;
  1924.         }
  1925.  
  1926.            // Search header for ->pas filename
  1927.           pasFileRE->Clear();
  1928.           PasFileSearch->SearchForString(".pas", 1, 0, "Include");
  1929.           if (PasFileSearch->PosFound != -1) {
  1930.              Line = hppFileRE->Lines->
  1931.                         Strings[PasFileSearch->LineNumFound];
  1932.              while (!GotPasName) {
  1933.                 OneChar = Line.SubString(PasFileSearch->
  1934.                           PosFound - PasFileSearch->
  1935.                           LinePosOne - CharCount, 1);
  1936.                 if ((OneChar == " ") || (OneChar == "/"))
  1937.                     GotPasName=true;
  1938.                 if (!GotPasName) {
  1939.                        AppendStr(OneChar, PasFileName);
  1940.                        PasFileName = OneChar;
  1941.                        CharCount++;
  1942.                    }
  1943.             }
  1944.              AppendStr(PasFileName,".pas");
  1945.         }
  1946.  
  1947.           // Empty table
  1948.           DestTable->Close();
  1949.           DestTable->TableName = "main2.db";
  1950.           DestTable->Open();
  1951.           DestTable->Close();
  1952.           DestTable->EmptyTable();
  1953.           DestTable->Open();
  1954.  
  1955.           // Parse and load
  1956.           RawVCLTable->Free();
  1957.           RawVCLTable = new TCloneTable(DestTable, True);
  1958.           RawVCLTable->Open();
  1959.           MainDS->DataSet = RawVCLTable;
  1960.           Grid->Refresh();
  1961.           RawVCLTable->First();
  1962.           HppToDestTable();
  1963.  
  1964.           // Clean up
  1965.           Screen->Cursor = crDefault;
  1966.           ViewParent->Enabled = false;
  1967.           MemberName1->Enabled = false;
  1968.           ClassName1->Enabled = false;
  1969.           TabRebuildStats->Hide();
  1970.           Enabled = true;
  1971.           int TotalPages = MembPgCtl->PageCount;
  1972.           for (int pg = 0; pg < TotalPages; pg++) {
  1973.              ClassLB->Items->Add(MembPgCtl->Pages[pg]->
  1974.                                   Caption);
  1975.         }    
  1976.         delete PasFileSearch;
  1977.         delete TabRebuildStats;
  1978.         MainPgCtl->ActivePage = MainPgCtl->Pages[1];
  1979.         MembersLV->Parent = MembPgCtl->ActivePage;
  1980.         MembersLV->Align = alClient;
  1981.     }
  1982. }
  1983.  
  1984. //------------------------------------------------------------
  1985. void __fastcall TMainForm::LoadVCLTableClick(TObject *Sender)
  1986. {
  1987.     // Reload the vcl table
  1988.      VCLTable->Close();
  1989.     VCLTable->TableName = "vcltable.db";
  1990.     VCLTable->Open();
  1991.  
  1992.     RawVCLTable->Free();
  1993.     RawVCLTable = new TCloneTable(VCLTable, True);
  1994.     RawVCLTable->Open();
  1995.     MainDS->DataSet = RawVCLTable;
  1996.     Grid->Refresh();
  1997.     RawVCLTable->First();
  1998.  
  1999.     ViewParent->Enabled = true;
  2000.     MemberName1->Enabled = true;
  2001.     ClassName1->Enabled = true;
  2002.     ClearTabs();
  2003.     MembPgCtl->MultiLine = true;
  2004.     LoadClasses();
  2005.     MainPgCtl->ActivePage = MainPgCtl->Pages[0];
  2006. }
  2007. //-------------------------------------------------------------
  2008.  
  2009. void __fastcall TMainForm::ClosePageClick(TObject *Sender)
  2010. {
  2011.        if (MembPgCtl->PageCount > 1) {
  2012.         int ActPage;
  2013.         ActPage = MembPgCtl->ActivePage->PageIndex;
  2014.         MembersLV->Parent = MembPgCtl->Pages[ActPage - 1];
  2015.           MembersLV->Items->Clear();
  2016.           MembPgCtl->ActivePage->Free();
  2017.           MembPgCtl->ActivePage = MembPgCtl->Pages[ActPage - 1];
  2018.           SelectATab(Sender);
  2019.     }
  2020. }
  2021. //------------------------------------------------------------
  2022.  
  2023. void __fastcall TMainForm::CloseAllClick(TObject *Sender)
  2024. {
  2025.     ClearTabs();
  2026.     SelectATab(Sender);
  2027. }
  2028. //------------------------------------------------------------
  2029.  
  2030. void TMainForm::ClearTabs()
  2031. {
  2032.     // Clear all tabs
  2033.     if (MembPgCtl->PageCount > 0) {
  2034.         MembPgCtl->ActivePage = MembPgCtl->Pages[MembPgCtl->PageCount - 1];
  2035.         MembersLV->Parent = MembPgCtl->ActivePage;
  2036.         int ActPage;
  2037.         ActPage = MembPgCtl->ActivePage->PageIndex;
  2038.         DeleteTabs = true;
  2039.  
  2040.           while (MembPgCtl->ActivePage != NULL) {
  2041.             if (MembPgCtl->PageCount == 1) break;
  2042.             MembersLV->Parent = MembPgCtl->Pages[ActPage - 1];
  2043.               MembersLV->Items->Clear();
  2044.               MembPgCtl->ActivePage->Free();
  2045.               MembPgCtl->ActivePage = MembPgCtl->Pages[ActPage - 1];
  2046.              Application->ProcessMessages();
  2047.             ActPage = ActPage - 1;
  2048.         }
  2049.           DeleteTabs = false;
  2050.     }
  2051. }
  2052.  
  2053. void TMainForm::LoadSourcePage()
  2054. {
  2055.     // Dump the .pas/.cpp into the richedit
  2056.        pasFileRE->Clear();
  2057.     SourceTab->Caption = "N/A";
  2058.        DoesFileExist = FileExists(LocalVclSource + "vcl\\" +
  2059.                                              CurrentSource);
  2060.        if (DoesFileExist) {
  2061.         pasFileRE->Lines->LoadFromFile(LocalVclSource
  2062.                                    + "vcl\\" + CurrentSource);
  2063.            SourceTab->Caption = CurrentSource;
  2064.     }
  2065.     else {
  2066.         DoesFileExist = FileExists(LocalVclSource +
  2067.                                 "toolsapi\\" + CurrentSource);
  2068.         if (DoesFileExist) {
  2069.             pasFileRE->Lines->
  2070.                             LoadFromFile(LocalVclSource +
  2071.                             "toolsapi\\" + CurrentSource);
  2072.             SourceTab->Caption = CurrentSource;
  2073.         }
  2074.         else
  2075.             pasFileRE->Lines->Strings[0] =
  2076.                         "Source Not Available for this Class!";
  2077.     }
  2078.     if(CurrentHeader.LowerCase() == "dstring.h") {
  2079.          DoesFileExist = FileExists(LocalVclSource +
  2080.                                     "vcl\\" + "dstring.cpp");
  2081.          if (DoesFileExist) {
  2082.             pasFileRE->Lines->
  2083.                             LoadFromFile(LocalVclSource +
  2084.                             "vcl\\" + "dstring.cpp");
  2085.             SourceTab->Caption = "dstring.cpp";
  2086.         }
  2087.     }
  2088.     if(CurrentHeader.LowerCase() == "wstring.h") {
  2089.          DoesFileExist = FileExists(LocalVclSource +
  2090.                                     "vcl\\" + "wstring.cpp");
  2091.          if (DoesFileExist) {
  2092.             pasFileRE->Lines->
  2093.                             LoadFromFile(LocalVclSource +
  2094.                             "vcl\\" + "wstring.cpp");
  2095.             SourceTab->Caption = "wstring.cpp";
  2096.         }
  2097.     }
  2098.        if(CurrentHeader.LowerCase() == "sysdefs.h") {
  2099.          DoesFileExist = FileExists(LocalVclSource +
  2100.                                     "vcl\\" + "Variant.cpp");
  2101.          if (DoesFileExist) {
  2102.             pasFileRE->Lines->
  2103.                             LoadFromFile(LocalVclSource +
  2104.                             "vcl\\" + "Variant.cpp");
  2105.             SourceTab->Caption = "Variant.cpp";
  2106.         }
  2107.     }
  2108. }
  2109.  
  2110. void __fastcall TMainForm::ChangeFonts(TObject *Sender)
  2111. {
  2112.     String String1;
  2113.     String String2;
  2114.     String1 = "\\software\\borland\\VCL Object Browser\\fonts";
  2115.     String2 = "\\software\\borland\\VCL Object Browser\\fonts\\size";
  2116.        int MyFontInteger;
  2117.        if (FontDialog1->Execute()) {
  2118.         if (Sender == SourcePage) pasFileRE->
  2119.                                 Font = FontDialog1->Font;
  2120.           if (Sender == HeaderPage) hppFileRE->
  2121.                                 Font = FontDialog1->Font;
  2122.           if (Sender == Declaration) DeclareRE->
  2123.                                 Font = FontDialog1->Font;
  2124.           if (Sender == Definition) DefineRE->
  2125.                                 Font = FontDialog1->Font;
  2126.           if (Sender == QuickClass) ClassLB->
  2127.                                 Font = FontDialog1->Font;
  2128.           if (Sender == MemberList) MembersLV->
  2129.                                 Font = FontDialog1->Font;
  2130.           if (Sender == Grid1) {
  2131.              Grid->Columns->Items[1]->Font = FontDialog1->Font;
  2132.              Grid->Columns->Items[2]->Font = FontDialog1->Font;
  2133.              Grid->Columns->Items[3]->Font = FontDialog1->Font;
  2134.              Grid->Columns->Items[4]->Font = FontDialog1->Font;
  2135.         }
  2136.  
  2137.           MyFontInteger = FontDialog1->Font->Color;
  2138.           int MyFontSize = FontDialog1->Font->Size;
  2139.           TRegistry *MyRegistry = new TRegistry();
  2140.           try {
  2141.                MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
  2142.              assert(MyRegistry->OpenKey(String1, false));
  2143.              if (Sender == SourcePage) MyRegistry->WriteString(
  2144.                     "DefinitionPage", IntToStr(MyFontInteger));
  2145.              if (Sender == HeaderPage) MyRegistry->WriteString(
  2146.                     "HeaderPage", IntToStr(MyFontInteger));
  2147.              if (Sender == Declaration) MyRegistry->WriteString(
  2148.                     "Declaration", IntToStr(MyFontInteger));
  2149.              if (Sender == Definition)  MyRegistry->WriteString(
  2150.                     "Definition", IntToStr(MyFontInteger));
  2151.              if (Sender == QuickClass)  MyRegistry->WriteString(
  2152.                     "QuickClass", IntToStr(MyFontInteger));
  2153.              if (Sender == MemberList)  MyRegistry->WriteString(
  2154.                     "MemberList", IntToStr(MyFontInteger));
  2155.              if (Sender == Grid1)  MyRegistry->WriteString(
  2156.                     "Grid", IntToStr(MyFontInteger));
  2157.          }
  2158.          catch(ERegistryException &E) {
  2159.                ShowMessage(E.Message);
  2160.             delete MyRegistry;
  2161.             return;
  2162.          }
  2163.  
  2164.           try {
  2165.                MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
  2166.              assert(MyRegistry->OpenKey(String2, false));
  2167.              if (Sender == SourcePage) MyRegistry->WriteString(
  2168.                     "DefinitionPage", IntToStr(MyFontSize));
  2169.              if (Sender == HeaderPage) MyRegistry->WriteString(
  2170.                     "HeaderPage", IntToStr(MyFontSize));
  2171.              if (Sender == Declaration) MyRegistry->WriteString(
  2172.                     "Declaration", IntToStr(MyFontSize));
  2173.              if (Sender == Definition)  MyRegistry->WriteString(
  2174.                     "Definition", IntToStr(MyFontSize));
  2175.              if (Sender == QuickClass)  MyRegistry->WriteString(
  2176.                     "QuickClass", IntToStr(MyFontSize));
  2177.              if (Sender == MemberList)  MyRegistry->WriteString(
  2178.                     "MemberList", IntToStr(MyFontSize));
  2179.              if (Sender == Grid1)  MyRegistry->WriteString(
  2180.                     "Grid", IntToStr(MyFontSize));
  2181.         }
  2182.         catch(ERegistryException &E) {
  2183.                ShowMessage(E.Message);
  2184.             delete MyRegistry;
  2185.             return;
  2186.         }
  2187.         delete MyRegistry;
  2188.         TFontStyles FStyle;
  2189.            // FStyle << fsBold;
  2190.            ClassLB->Font->Style = FStyle;
  2191.     }
  2192. }
  2193.  
  2194. //------------------------------------------------------------
  2195. void __fastcall TMainForm::ChangeBkgnds(TObject *Sender)
  2196. {
  2197.     String String1 = "\\software\\borland\\VCL Object Browser\\colors";
  2198.     if (ColorDialog1->Execute()) {
  2199.         if (Sender == SourcePage2) pasFileRE->
  2200.                                 Color = ColorDialog1->Color;
  2201.           if (Sender == HeaderPage2) hppFileRE->
  2202.                                 Color = ColorDialog1->Color;
  2203.           if (Sender == Declaration2) DeclareRE->
  2204.                                 Color = ColorDialog1->Color;
  2205.           if (Sender == Definition2)  DefineRE->
  2206.                                 Color = ColorDialog1->Color;
  2207.           if (Sender == QuickClass2)  ClassLB->
  2208.                                 Color = ColorDialog1->Color;
  2209.           if (Sender == MemberList2)  MembersLV->
  2210.                                 Color = ColorDialog1->Color;
  2211.           if (Sender == Grid2)  Grid->
  2212.                                 Color = ColorDialog1->Color;
  2213.           TRegistry *MyRegistry = new TRegistry();
  2214.           try {
  2215.              MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
  2216.              assert(MyRegistry->OpenKey(String1, false));
  2217.              if (Sender == SourcePage2) MyRegistry->WriteString(
  2218.                                 "DefinitionPage",
  2219.                                 IntToStr(ColorDialog1->Color));
  2220.              if (Sender == HeaderPage2) MyRegistry->WriteString(
  2221.                                 "HeaderPage",
  2222.                                 IntToStr(ColorDialog1->Color));
  2223.              if (Sender == Declaration2) MyRegistry->WriteString(
  2224.                                 "Declaration",
  2225.                                 IntToStr(ColorDialog1->Color));
  2226.              if (Sender == Definition2) MyRegistry->WriteString(
  2227.                                 "Definition",
  2228.                                 IntToStr(ColorDialog1->Color));
  2229.              if (Sender == QuickClass2) MyRegistry->WriteString(
  2230.                                 "QuickClass",
  2231.                                 IntToStr(ColorDialog1->Color));
  2232.              if (Sender == MemberList2)  MyRegistry->WriteString(
  2233.                                 "MemberList",
  2234.                                 IntToStr(ColorDialog1->Color));
  2235.  
  2236.              if (Sender == Grid2)MyRegistry->WriteString("Grid",
  2237.                                 IntToStr(ColorDialog1->Color));
  2238.          }
  2239.          catch(ERegistryException &E) {
  2240.                ShowMessage(E.Message);
  2241.             delete MyRegistry;
  2242.             return;
  2243.          }
  2244.          delete MyRegistry;
  2245.     }
  2246. }
  2247. //------------------------------------------------------------
  2248.  
  2249. int TMainForm::FindImageIndex(const String Scope,
  2250.                                         const String Member)
  2251. {
  2252.     bool a = Scope == "public";
  2253.     bool b = Scope == "__published";
  2254.     bool c = Scope == "protected";
  2255.     bool d = Scope == "private";
  2256.  
  2257.     bool h = Member == "function";
  2258.     bool i = Member == "data";
  2259.     bool j = Member == "constructor";
  2260.     bool k = Member == "property";
  2261.  
  2262.     if ((c) && (h)) return(0);
  2263.     if ((c) && (i)) return(1);
  2264.     if ((c) && (j)) return(2);
  2265.     if ((c) && (k)) return(3);
  2266.     if ((b) && (h)) return(4);
  2267.     if ((b) && (i)) return(5);
  2268.     if ((b) && (j)) return(6);
  2269.     if ((b) && (k)) return(7);
  2270.     if ((d) && (h)) return(8);
  2271.     if ((d) && (i)) return(9);
  2272.     if ((d) && (j)) return(10);
  2273.     if ((d) && (k)) return(11);
  2274.     if ((a) && (h)) return(12);
  2275.     if ((a) && (i)) return(13);
  2276.     if ((a) && (j)) return(14);
  2277.     if ((a) && (k)) return(15);
  2278.     return(0);
  2279. }
  2280.  
  2281. void __fastcall TMainForm::ViewParentClick(TObject *Sender)
  2282. {   
  2283.     ClassLBSel = RawVCLTable->FieldByName("SecondClass")->AsString;
  2284.        if ((ClassLBSel != ""))    {
  2285.           Grid->DataSource = MainDS;
  2286.           RawVCLTable->Refresh();
  2287.           Screen->Cursor = crHourGlass;
  2288.           RawVCLTable->DisableControls();
  2289.           RawVCLTable->Filtered = false;
  2290.           RawVCLTable->SetRange(OPENARRAY(TVarRec, (ClassLBSel)),
  2291.                          OPENARRAY(TVarRec, (ClassLBSel)));
  2292.           CurrentHeader = RawVCLTable->FieldByName("Header")->AsString;
  2293.           CurrentSource = RawVCLTable->FieldByName("Misc")->AsString;
  2294.           TTabSheet *NewTabSheet = new TTabSheet(this);
  2295.           NewTabSheet->Caption = ClassLBSel;
  2296.           NewTabSheet->PageControl = MembPgCtl;
  2297.         MembersLV->Parent = NewTabSheet;
  2298.            MembersLV->Align = alClient;
  2299.           MembPgCtl->ActivePage = MembPgCtl->Pages
  2300.                                 [MembPgCtl->PageCount - 1];
  2301.           TableToListStrings(ClassLBSel);
  2302.           hppFileRE->Clear();
  2303.           try {
  2304.             hppFileRE->Lines->LoadFromFile(
  2305.                             LocalVclHeaders + CurrentHeader);
  2306.              HeaderTab->Caption = CurrentHeader;
  2307.         }
  2308.         catch(EFOpenError& E) {
  2309.             ShowMessage(E.Message);
  2310.             Screen->Cursor = crDefault;
  2311.             return;
  2312.         }
  2313.           LoadSourcePage();
  2314.           RawVCLTable->First();
  2315.           RawVCLTable->EnableControls();
  2316.           Screen->Cursor = crDefault;
  2317.     }
  2318.     else
  2319.         ShowMessage("No class derivation info available!");
  2320. }
  2321. //------------------------------------------------------------
  2322.  
  2323. void TMainForm::ProcessSelectedClass()
  2324. {
  2325.     MainPgCtl->ActivePage = MainPgCtl->Pages[1];
  2326.        MemberNameSel = "";
  2327.        DefLength = 0;
  2328.        VCLTable->IndexName = "";
  2329.        MainDS->DataSet = RawVCLTable;
  2330.        Screen->Cursor = crHourGlass;
  2331.        RawVCLTable->DisableControls();
  2332.        RawVCLTable->Filtered = false;
  2333.        RawVCLTable->SetRange(OPENARRAY(TVarRec, (ClassLBSel)),
  2334.                           OPENARRAY(TVarRec, (ClassLBSel)));
  2335.        RawVCLTable->First();
  2336.        CurrentHeader = RawVCLTable->FieldByName("Header")->AsString;
  2337.        CurrentSource = RawVCLTable->FieldByName("Misc")->AsString;
  2338.        TTabSheet *NewTabSheet = new TTabSheet(this);
  2339.        NewTabSheet->Caption = ClassLBSel;
  2340.        NewTabSheet->PageControl = MembPgCtl;
  2341.     MembersLV->Parent = NewTabSheet;
  2342.     MembersLV->Align = alClient;
  2343.        MembPgCtl->ActivePage = MembPgCtl->Pages
  2344.                                 [MembPgCtl->PageCount - 1];
  2345.     MembersLV->ViewStyle = vsList;
  2346.     Application->ProcessMessages();
  2347.        TableToListStrings(ClassLBSel);
  2348.        RawVCLTable->First();
  2349.        pasFileRE->Clear();
  2350.        LoadSourcePage();
  2351.        try {
  2352.         hppFileRE->Lines->LoadFromFile(
  2353.                             LocalVclHeaders + CurrentHeader);
  2354.           HeaderTab->Caption = CurrentHeader;
  2355.     }
  2356.     catch(EFOpenError& E) {
  2357.         ShowMessage(E.Message);
  2358.         Screen->Cursor = crDefault;
  2359.         return;
  2360.     }
  2361.        RawVCLTable->EnableControls();
  2362.        TObject *Sender = new TObject();
  2363.        delete Sender;
  2364.        Screen->Cursor = crDefault;
  2365. }
  2366.  
  2367. void __fastcall TMainForm::PublicLabClick(TObject *Sender)
  2368. {
  2369.     String PublicStr = "[Scope]='public'";
  2370.     String PublishStr = "[Scope]='__published'";
  2371.     String ProtectStr = "[Scope]='protected'";
  2372.     String PrivateStr = "[Scope]='private'";
  2373.     String FilterStr = "";
  2374.  
  2375.     TToolButton *Tbtn = dynamic_cast<TToolButton *>(Sender);
  2376.     RawVCLTable->DisableControls();
  2377.     RawVCLTable->Filtered = false;
  2378.     if(Tbtn->Tag) {
  2379.         Tbtn->Down = false;
  2380.         Tbtn->Tag = 0;
  2381.     }
  2382.     else {
  2383.         Tbtn->Down = true;
  2384.         Tbtn->Tag = 1;
  2385.     }
  2386.  
  2387.     if (PublicBtn->Down) FilterStr = FilterStr + PublicStr;
  2388.     if ((PublishBtn->Down) && (PublicBtn->Down)) FilterStr =
  2389.         FilterStr + " OR " + PublishStr;
  2390.     else if (PublishBtn->Down) FilterStr = FilterStr + PublishStr;
  2391.     if ((ProtectBtn->Down && (PublishBtn->Down || PublicBtn->Down))) FilterStr =
  2392.         FilterStr + " OR " + ProtectStr;
  2393.     else if (ProtectBtn->Down) FilterStr = FilterStr + ProtectStr;
  2394.     if ((PrivateBtn->Down && (PublicBtn->Down || PublishBtn->Down ||
  2395.         ProtectBtn->Down))) FilterStr = FilterStr + " OR " + PrivateStr;
  2396.     else if (PrivateBtn->Down) FilterStr = FilterStr + PrivateStr;
  2397.  
  2398.     RawVCLTable->Filter = FilterStr;
  2399.     RawVCLTable->Filtered = true;
  2400.     RawVCLTable->First();
  2401.     TableToListStrings(ClassLBSel);
  2402.     RawVCLTable->Filtered = false;
  2403.     RawVCLTable->EnableControls();
  2404. }
  2405. //------------------------------------------------------------
  2406.  
  2407. void __fastcall TMainForm::ExitClick(TObject *Sender)
  2408. {
  2409.     Application->Terminate();
  2410. }
  2411. //------------------------------------------------------------
  2412.  
  2413. void __fastcall TMainForm::MembersLVKeyDown(TObject *Sender, WORD &Key,
  2414.     TShiftState Shift)
  2415. {
  2416.        if (Key == 13)MembersLVClick(Sender);
  2417. }
  2418.  
  2419. void __fastcall TMainForm::ViewMultipleClick(TObject *Sender)
  2420. {
  2421.    //    MembersLV->ViewStyle = vsList;
  2422.        //SelectATab(Sender);
  2423. }
  2424. //------------------------------------------------------------
  2425.  
  2426. void __fastcall TMainForm::ViewExpandedClick(TObject *Sender)
  2427. {
  2428.     //MembersLV->ViewStyle = vsReport;
  2429. }
  2430. //------------------------------------------------------------
  2431.  
  2432. void __fastcall TMainForm::OpenhppcppClick(TObject *Sender)
  2433. {
  2434.        // Get File Name 
  2435.        FileOpenDlg->InitialDir = LocalVclHeaders;
  2436.        FileOpenDlg->Options << ofHideReadOnly;
  2437.        FileOpenDlg->Filter = "*.hpp,*.h,*.cpp,*.c|*.hpp;*.h;*.cpp;*.c";
  2438.        if (FileOpenDlg->Execute()) {
  2439.           hppFileRE->Lines->LoadFromFile(
  2440.                                     FileOpenDlg->FileName);
  2441.         pasFileRE->Clear();
  2442.           Show();
  2443.     }
  2444.     MainPgCtl->ActivePage = MainPgCtl->Pages[4];
  2445. }
  2446. //------------------------------------------------------------
  2447.  
  2448. TExtractObjects::TExtractObjects()
  2449. {
  2450. }
  2451.  
  2452. void TExtractObjects::ExtractNameAndType(int StartPosition,
  2453.                 int EndPos, String LineString, String Phase)
  2454. {
  2455.     int AProperty;
  2456.     int StartRetType;
  2457.     int FirstCharPos;
  2458.     int x;
  2459.     int j;
  2460.        String a;
  2461.        bool NoReturnType = false;
  2462.        ObjectName = "";
  2463.        ObjectType = "";
  2464.  
  2465.        x = EndPos;
  2466.        LastCommaPosition = EndPos;
  2467.        x = x - 1;
  2468.        a = LineString.SubString(x, 1);
  2469.  
  2470.     // Skip tabs and spaces
  2471.        while ((a == " ")|| (a == "\t")) {
  2472.         x--;
  2473.           a = LineString.SubString(x, 1);
  2474.     }
  2475.        while ((a != " ") && (a != "(") && (a != "\t")
  2476.                           && (a != ",") && (a != "{")
  2477.                           && (a != "*")) {
  2478.            a=LineString.SubString(x, 1);
  2479.           if (a == "{") NoReturnType = true;
  2480.           x--;
  2481.     }
  2482.        x = x + 2;
  2483.        FirstCharPos = x;
  2484.        a = LineString.SubString(x, 1);
  2485.        AProperty = LineString.Pos("__property");
  2486.  
  2487.        // Handle extracting property names differently
  2488.        if ((AProperty) && (Phase == "MemberName")) {
  2489.         while ((a != "=") && (a != "}") &&
  2490.                (a != ";")) {
  2491.             ObjectName = ObjectName+a;
  2492.              x++;
  2493.              a = LineString.SubString(x, 1);
  2494.         }
  2495.     }
  2496.     else {// extract object name
  2497.         while ((a != " ") && (a != "\t")  &&
  2498.                (a != ";") && (a != ",")
  2499.                && (a != "(") && (a != ")")
  2500.                && (a != "{") && (a != "}")) {
  2501.             ObjectName = ObjectName + a;
  2502.             x++;
  2503.             a = LineString.SubString(x, 1);
  2504.         }
  2505.     }
  2506.  
  2507.        // extract return type
  2508.        if (FirstCharPos == 1) NoReturnType = true;
  2509.        FirstCharPos = FirstCharPos - 1;
  2510.        a = LineString.SubString(FirstCharPos, 1);
  2511.  
  2512.        // eliminate operator in return type
  2513.        int OperatorLine = LineString.Pos("operator");
  2514.        if ((OperatorLine) && (Phase=="MemberName")) {
  2515.           FirstCharPos = OperatorLine - 1;
  2516.           ObjectName = "operator " + ObjectName;
  2517.     }
  2518.  
  2519.        //backup until found last letter of Return Type
  2520.        while ((a==" ") && (!NoReturnType)) {
  2521.         if (FirstCharPos == 1) NoReturnType = true;
  2522.         FirstCharPos--;
  2523.           a = LineString.SubString(FirstCharPos, 1);
  2524.     }
  2525.  
  2526.        if (!NoReturnType) {
  2527.           StartRetType = StartPosition;
  2528.           a = LineString.SubString(StartRetType, 1);
  2529.         // find start pos of ReturnType
  2530.           while (a == " ") {
  2531.             StartRetType = StartRetType + 1;
  2532.              a = LineString.SubString(StartRetType, 1);
  2533.         }
  2534.           for (j = StartRetType; j <= FirstCharPos; j++) {
  2535.              a = LineString.SubString(j, 1);
  2536.              if (a != "\t") ObjectType = ObjectType + a;
  2537.         }
  2538.     }
  2539. }
  2540.  
  2541. TSearchEngine::TSearchEngine()
  2542. }
  2543.  
  2544. void TSearchEngine::SearchForString(String Word, int Occurance,
  2545.                              int StartPosition, String Page)
  2546. {
  2547.     TFindText MyTFindText;
  2548.     int OccuranceCount;
  2549.     String SearchValue;
  2550.     OccuranceCount = 0;
  2551.     SearchValue = Word;
  2552.     NewSearchPos = 0;
  2553.     LineNumFound = 0;
  2554.     LinePosOne = 0;
  2555.     PosFound = 0;
  2556.  
  2557.     // Setup Find Text struct
  2558.     MyTFindText.chrg.cpMin = StartPosition;
  2559.     MyTFindText.chrg.cpMax = -1;
  2560.     MyTFindText.lpstrText = Word.c_str();
  2561.  
  2562.     // If none found stop at defined Occurance
  2563.     while ((PosFound != -1) && (OccuranceCount != Occurance)) {
  2564.         if (Page == "Include") PosFound = 
  2565.             MainForm->hppFileRE->Perform(EM_FINDTEXT, FT_MATCHCASE,
  2566.                                long(&MyTFindText));
  2567.           if (Page == "Source") PosFound = 
  2568.             MainForm->pasFileRE->Perform(EM_FINDTEXT, FT_MATCHCASE,
  2569.                                long(&MyTFindText));
  2570.           if ((PosFound != -1) && (OccuranceCount != Occurance)) {
  2571.              if (Page == "Include") {
  2572.                 MainForm->hppFileRE->Perform(EM_SETSEL,
  2573.                                          PosFound, PosFound);
  2574.                 LineNumFound = MainForm->hppFileRE->
  2575.                         Perform(EM_LINEFROMCHAR,
  2576.                         MainForm->hppFileRE->SelStart, 0);
  2577.                 LinePosOne = MainForm->hppFileRE->
  2578.                         Perform(EM_LINEINDEX, LineNumFound, 0);
  2579.             }
  2580.             if (Page == "Source") {
  2581.                 MainForm->pasFileRE->Perform(EM_SETSEL,
  2582.                                          PosFound, PosFound);
  2583.                 LineNumFound = MainForm->pasFileRE->Perform(
  2584.                            EM_LINEFROMCHAR,
  2585.                            MainForm->pasFileRE->SelStart, 0);
  2586.                 LinePosOne = MainForm->pasFileRE->
  2587.                         Perform(EM_LINEINDEX, LineNumFound, 0);
  2588.             }
  2589.             MyTFindText.chrg.cpMin = PosFound + 1;
  2590.             NewSearchPos = PosFound + 1;
  2591.             OccuranceCount++;
  2592.         }
  2593.     if (PosFound == -1) LineNumFound = 999999;
  2594.     }
  2595.  
  2596. void TMainForm::LoadCppDef(const String ParamArray[8],
  2597.                                         const int ParamQty)
  2598. {
  2599.     String CodeLine;
  2600.     String OneChar;
  2601.     String CndseStr = "";
  2602.     String LBString;
  2603.     String CNString;
  2604.     String HMemCndns = "";
  2605.     String PString;
  2606.     String CndnsPType;
  2607.     bool Match = false;
  2608.     bool FirstChar = false;
  2609.     bool FoundCName = false;
  2610.     bool FoundPT = false;
  2611.     bool Break;
  2612.     bool OpenBrkt;
  2613.     int MyCount;
  2614.     int b;
  2615.     int StrLength;
  2616.     int OpenParen;
  2617.     int ClosedParen;
  2618.     int Diff;
  2619.     int Len;
  2620.     int x;
  2621.     int c;
  2622.     int CheckAnsiString;
  2623.     int CheckString;
  2624.     int OccurNum = 1;
  2625.     TStringList *DeclareSList = new TStringList();
  2626.     TSearchEngine *MDeclareSearch = new TSearchEngine();
  2627.  
  2628.     // strip spaces and tabs from selected item
  2629.     CNString = CurrentTab + "::" + MemberNameSel;
  2630.     Len = CNString.Length();
  2631.     for (x = 1; x <= Len; x++) {
  2632.         OneChar = CNString.SubString(x, 1);
  2633.           if ((OneChar != " ") && (OneChar != "\t")) CndseStr =
  2634.                                         CndseStr + OneChar;
  2635.     }
  2636.  
  2637.     // Search for member name
  2638.     while (!Match) {
  2639.         if (MemberNameSel.Pos("operator") > 0)
  2640.                                 MemberNameSel = "operator";
  2641.  
  2642.          // Its best to search for only the function name
  2643.         // because we would have to condense the whole .cpp file
  2644.           MDeclareSearch->SearchForString("::" + MemberNameSel,
  2645.                                      OccurNum, 0, "Source");
  2646.           if (MDeclareSearch->PosFound == -1) {
  2647.              DefineRE->Clear();
  2648.              DefineRE->Lines->Add("Definition not found!");
  2649.              return;
  2650.         }
  2651.  
  2652.            // piece together the complete function
  2653.           Break = false;
  2654.           OpenBrkt = false;
  2655.           MyCount = 0;
  2656.           b = 0;
  2657.           while (!Break) {
  2658.             x = 1;
  2659.              CodeLine = "";
  2660.              StrLength = pasFileRE->Lines->
  2661.             Strings[MDeclareSearch->LineNumFound + b].Length();
  2662.              while ((x != StrLength + 1) && (!Break)) {
  2663.                 OneChar = pasFileRE->Lines->
  2664.                         Strings[MDeclareSearch->
  2665.                         LineNumFound + b].SubString(x, 1);
  2666.                 if (OneChar == "{") {
  2667.                        OpenBrkt = true;
  2668.                        MyCount = MyCount + 1;
  2669.                 }
  2670.                 if (OneChar == "}") MyCount = MyCount - 1;
  2671.                 if ((!MyCount) && (OpenBrkt)) Break = true;
  2672.                 if ((OneChar != " ") && (OneChar != "\t")) {
  2673.                        FirstChar = true;
  2674.                    // Condense it
  2675.                    HMemCndns = HMemCndns + OneChar;
  2676.                    }
  2677.                 if (FirstChar) CodeLine = CodeLine + OneChar;
  2678.                 x++;
  2679.             }
  2680.              DeclareSList->Add(CodeLine);
  2681.              FirstChar = false;
  2682.              b++;
  2683.         }
  2684.  
  2685.           /* Once we have the complete function stripped and in a
  2686.            String, check params to see if correct definition */
  2687.           if (ParamQty == 0) {
  2688.             if (HMemCndns.Pos(CndseStr + "()"))
  2689.              FoundCName = true;
  2690.              FoundPT = true;
  2691.         }
  2692.         else {
  2693.             if (HMemCndns.Pos(CndseStr)) {
  2694.                 // Lets get the pos of first of  "(" and ")"
  2695.                    OpenParen = HMemCndns.Pos("(");
  2696.                    ClosedParen = HMemCndns.Pos(")");
  2697.                    Diff = ClosedParen - OpenParen;
  2698.                    PString = HMemCndns.SubString(OpenParen + 1,
  2699.                                               Diff - 1);
  2700.                    FoundCName = true;
  2701.                      for(c = 0; c < ParamQty; c++) {
  2702.                     FoundPT = false;
  2703.                          CndnsPType = "";
  2704.                       // Strip and condense Param Type
  2705.                       for(x = 1; x <= (ParamArray[c].Length()); x++) {
  2706.                           OneChar = ParamArray[c].SubString(x, 1);
  2707.                          if ((OneChar != " ") && (OneChar != "\t"))
  2708.                              CndnsPType = CndnsPType + OneChar;
  2709.                     }
  2710.                       if (PString.Pos(CndnsPType))
  2711.                         FoundPT = true;
  2712.                     else {
  2713.                         CheckAnsiString =
  2714.                                 CndnsPType.Pos("AnsiString");
  2715.                         if (CheckAnsiString) {
  2716.                             // delete "AnsiString"
  2717.                             CndnsPType.Delete(CheckAnsiString,10);
  2718.                             // insert "String"
  2719.                             CndnsPType.Insert("String",
  2720.                                          CheckAnsiString);
  2721.                             if (PString.Pos(CndnsPType))
  2722.                                 FoundPT = true;
  2723.                             else {
  2724.                                 CheckString =
  2725.                                       CndnsPType.Pos("String");
  2726.                                    if (CheckString){
  2727.                                      // delete "String"
  2728.                                      CndnsPType.Delete(CheckString,
  2729.                                                          6);
  2730.                                     // insert "AnsiString"
  2731.                                       CndnsPType.Insert("AnsiString",
  2732.                                                  CheckString);
  2733.                                     if (PString.Pos(CndnsPType))
  2734.                                         FoundPT = true;
  2735.                                     }
  2736.                                  }
  2737.                             }
  2738.                         }
  2739.                            if (!FoundPT)break;
  2740.                     }
  2741.                 }
  2742.             }
  2743.               if ((FoundPT) && (FoundCName))
  2744.                 Match = true;
  2745.             else {
  2746.                 HMemCndns = "";
  2747.                   OccurNum++;
  2748.                    DeclareSList->Clear();
  2749.             }
  2750.     }
  2751.     DefineRE->Clear();
  2752.     DefineRE->Lines->AddStrings(DeclareSList);
  2753.     DefineRE->SetFocus();
  2754.     DefineRE->Perform(EM_SETSEL, 0, 0);
  2755.     delete DeclareSList;
  2756.     delete MDeclareSearch;
  2757. } // one bug:  constructors with 1 parameter char and  char*
  2758.  
  2759. void __fastcall TMainForm::MainPgCtlChange(TObject *Sender)
  2760. {
  2761.     int PgIndex = MainPgCtl->ActivePage->PageIndex;
  2762.     if (PgIndex == 4) ViewHeaderClick(Sender);
  2763.     if (PgIndex == 5) ViewSourceClick(Sender);
  2764. }
  2765. //---------------------------------------------------------------------------
  2766.  
  2767. void __fastcall TMainForm::RestrictSize(TMessage& Msg)
  2768. {
  2769.      ((POINT far *)Msg.LParam)[3].x = 480;
  2770.      ((POINT far *)Msg.LParam)[3].y = 400;
  2771.      TForm::Dispatch(&Msg);
  2772. }
  2773.  
  2774. void __fastcall TMainForm::Print(TObject *Sender)
  2775. {
  2776.     TMenuItem* Item;
  2777.     Item = dynamic_cast<TMenuItem *>(Sender);
  2778.  
  2779.     if (Item->Caption == "Print Header file")
  2780.              if(PrintDialog1->Execute())hppFileRE->Print(CurrentHeader);
  2781.     if (Item->Caption == "Print Source file")
  2782.              if(PrintDialog1->Execute())pasFileRE->Print(CurrentSource);
  2783.     if (Item->Caption == "Print Prototype")
  2784.              if(PrintDialog1->Execute()) DeclareRE->Print(MemberNameSel + " Prototype");
  2785.     if (Item->Caption == "Print Definition")
  2786.              if(PrintDialog1->Execute()) DefineRE->Print(MemberNameSel + " Definition");
  2787.  
  2788. }
  2789. //------------------------------------------------------------
  2790.  
  2791.  
  2792. void __fastcall TMainForm::FindDlgFind(TObject *Sender)
  2793. {
  2794.     int Page;
  2795.     Page = MainPgCtl->ActivePage->PageIndex;
  2796.     if (Page < 4) return;
  2797.     const String Search = FindDlg->FindText;
  2798.  
  2799.     // Setup search struct
  2800.     bool FoundOne;
  2801.     TFindText MyTFindText;
  2802.     MyTFindText.chrg.cpMin = PosFound;
  2803.     if (PosFound) MyTFindText.chrg.cpMin = PosFound + Search.Length();
  2804.     MyTFindText.chrg.cpMax = -1;
  2805.     MyTFindText.lpstrText = strdup(Search.c_str());
  2806.  
  2807.     //String temptab = MainPgCtl->ActivePage->Caption;
  2808.  
  2809.     TRichEdit *RE = (TRichEdit *) MainPgCtl->ActivePage->Controls[0];
  2810.     PosFound = RE->Perform(EM_FINDTEXT, FT_WHOLEWORD, (LPARAM) (&MyTFindText));
  2811.     FoundOne = PosFound != -1;
  2812.     RE->Perform(EM_SETSEL, PosFound, PosFound + Search.Length());
  2813.     RE->Perform(EM_SCROLLCARET, 0, 0);
  2814.     RE->SetFocus();
  2815.  
  2816.     if (!FoundOne) {
  2817.        ShowMessage("End of Page! \"" + Search +  "\" not found!");
  2818.        return;
  2819.     }
  2820. }
  2821. //---------------------------------------------------------------------------
  2822.  
  2823. void __fastcall TMainForm::Find1Click(TObject *Sender)
  2824. {
  2825.     if (FindDlg->Execute())    {
  2826.         PosFound = 0;
  2827.         FindNext1->Enabled = true;
  2828.     }
  2829. }
  2830. //--------------------------------------------------------------------------- 
  2831.  
  2832. void __fastcall TMainForm::ClassLBKeyDown(TObject *Sender, WORD &Key,
  2833.       TShiftState Shift)
  2834. {
  2835.     if (Key == 13)ClassLBClick(Sender);       
  2836. }
  2837. //---------------------------------------------------------------------------
  2838.  
  2839. void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
  2840. {
  2841.     Action = caFree;
  2842.     MainForm = NULL;
  2843.     ClassOrgDB->Connected = false;
  2844. }
  2845. //------------------------------------------------------------
  2846.